《PHP編程:Yii視圖CGridView列表用法實例分析》要點:
本文介紹了PHP編程:Yii視圖CGridView列表用法實例分析,希望對您有用。如果有疑問,可以聯系我們。
相關主題:YII框架
PHP應用本文實例講述了Yii視圖CGridView列表用法.分享給大家供大家參考,具體如下:
PHP應用CGridView列表實例
PHP應用
<!-- 列表 -->
<?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'//查看按鈕設為不可見
)
)
)
)
));
?>
PHP應用修改基類,定義底部功能菜單framework/zii/widgets/grid/CGridView.php(152)
PHP應用
public function renderFooterCell()
{
if(trim($this->footer)!==''){
echo CHtml::openTag('td',$this->footerHtmlOptions);
$this->renderFooterCellContent();
echo '</td>';
}
}
PHP應用修改視圖,實現底部功能按鈕列表
PHP應用
'columns'=>array(
array(
'class'=>'CCheckBoxColumn',
'footer'=>'<button onclink="deleteAll()">button</button>
<button onclink="refashAll()">button</button>',
'footerHtmlOptions'=>array('colspan'=>5),
'selectableRows'=>2,
),
PHP應用更多關于Yii相關內容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優秀開發框架總結》、《smarty模板入門基礎教程》、《php日期與時間用法總結》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》
PHP應用希望本文所述對大家基于Yii框架的PHP程序設計有所幫助.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/5686.html