Yii视图CGridView列表用法实例分析

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, ),

更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5f1c3d4bebd22e6d89c420b06077c9d8.html