本文实例讲述了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常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
本文地址:https://www.stayed.cn/item/24344
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我