根据dataSource中提供的值渲染出来的页面效果如下:
最后一列的操作,根据是否已经处理来显示“回收”的操作按钮。
相关代码如下,主要是template中使用条件判断语句的方式:
var kendoGridPermissionApplys = $("#kendo_grid_permission_applys").kendoGrid( { dataSource:{ data:<?php echo $test;?> }, sortable: true, scrollable: false, selectable: true, pageable:{ messages:{ display: "<?php echo Yii::t('default', 'Showing {0}-{1} from {2} data items'); ?>", empty: "<?php echo Yii::t('default', 'No items to display'); ?>", first: "<?php echo Yii::t('default', 'Go to the first page'); ?>", previous: "<?php echo Yii::t('default', 'Go to the previous page'); ?>", next: "<?php echo Yii::t('default', 'Go to the next page'); ?>", last: "<?php echo Yii::t('default', 'Go to the last page'); ?>" } }, columns:[ { field:"apply_from", title: "<?php echo Yii::t('default', 'Apply From'); ?>" }, { field:"apply_contents", title: "<?php echo Yii::t('default', 'Apply Contents'); ?>" }, { field:"apply_status", title: "<?php echo Yii::t('default', 'Apply Status'); ?>" }, { field:"apply_create_time", title: "<?php echo Yii::t('default', 'Apply Create Time'); ?>" }, { template: "<a class='k-button' href='index.php?r=apply/admin/showapply&apply_id=#=apply_id#&apply_from=#=apply_from#' style='min-width:24px'>查看</a><a class='k-button' style='min-width:24px' onclick='IfGoToDistributePermission(#=apply_id# ,#=apply_status_en#)'>分配</a>" + "# if (apply_status_en == 2) { #" + "<a class='k-button' onclick='RecyclePermission(#=apply_id#)'>回收</a>" + "# } #", title:"<?php echo Yii::t('default', 'Operate'); ?>" } ] }).data("kendoGrid");
KendoUi控件kendoGrid中template中条件判断的使用
原文地址:http://blog.csdn.net/houqd2012/article/details/44065685