Yii視圖CGridView列表用法實例分析
本文實例講述了Yii視圖CGridView列表用法。分享給大家供大家參考,具體如下:
CGridView列表實例
<!-- 列表 --> <?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'words-grid', 'dataProvider'=>$model->search(),//數(shù)據(jù)源 '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)',//數(shù)據(jù)轉(zhuǎn)換 ), '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>'; } }
修改視圖,實現(xiàn)底部功能按鈕列表
'columns'=>array( array( 'class'=>'CCheckBoxColumn', 'footer'=>'<button onclink="deleteAll()">button</button> <button onclink="refashAll()">button</button>', 'footerHtmlOptions'=>array('colspan'=>5), 'selectableRows'=>2, ),
更多關于Yii相關內(nèi)容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優(yōu)秀開發(fā)框架總結》、《smarty模板入門基礎教程》、《php日期與時間用法總結》、《php面向?qū)ο蟪绦蛟O計入門教程》、《php字符串(string)用法總結》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。