本文实例讲述了Yii视图CGridView列表用法。分享给大家供大家参考,具体如下:
CGridView列表实例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<!-- 列表 --> <?php $this ->widget( 'zii.widgets.grid.CGridView' , array ( 'id' => 'words-grid' , 'dataProvider' => $model ->search(), //数据源 'filter' => $model , //设置过滤器,筛选输入框 'columns' => array ( array ( 'class' => 'CCheckBoxColumn' , //选择框 'htmlOptions' => array ( 'width' => "30px" ), ), 'zw_id' , 'zw_title' , array ( 'name' => 'zw_level' , 'value' => 'Words::model()->getLevel($data->zw_level)' , //数据转换 ), 'zw_replaceword' , 'zw_listorder' , array ( 'name' => 'inputtime' , 'value' => 'date("Y-m-d",$data->inputtime)' , //格式化日期 ), array ( 'class' => 'CButtonColumn' , 'buttons' => array ( 'view' => array ( 'visible' => 'false' //查看按钮设为不可见 ) ) ) ) )); ?> |
修改基类,定义底部功能菜单framework/zii/widgets/grid/CGridView.php(152)
1
2
3
4
5
6
7
8
|
public function renderFooterCell() { if (trim( $this ->footer)!== '' ){ echo CHtml::openTag( 'td' , $this ->footerHtmlOptions); $this ->renderFooterCellContent(); echo '</td>' ; } } |
修改视图,实现底部功能按钮列表
1
2
3
4
5
6
7
8
|
'columns' => array ( array ( 'class' => 'CCheckBoxColumn' , 'footer' =>'<button onclink= "deleteAll()" >button</button> <button onclink= "refashAll()" >button</button>', 'footerHtmlOptions' => array ( 'colspan' =>5), 'selectableRows' =>2, ), |
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。