CGridView列表实例
<!-- 列表 --> <?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)
public function renderFooterCell() { if(trim($this->footer)!==''){ echo CHtml::openTag('td',$this->footerHtmlOptions); $this->renderFooterCellContent(); echo '</td>'; } }
修改视图,实现底部功能按钮列表
'columns'=>array( array( 'class'=>'CCheckBoxColumn', 'footer'=>'<button onclink="deleteAll()">button</button> <button onclink="refashAll()">button</button>', 'footerHtmlOptions'=>array('colspan'=>5), 'selectableRows'=>2, ),