cbuttoncolumn

Custom column in CGridView with Button dropdowns's Twitter Bootstrap

纵然是瞬间 提交于 2019-12-13 05:39:21
问题 I just create Button dropdowns's Twitter Bootstrap for CGridView column. The button contains sub menus and each of them has attributes such as href, class, data- , etc.. which can set through dropdownMenuItems attribute in CGridView widget. In view $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$dataProvider, 'ajaxUpdate'=>false, 'columns'=>array( array( 'name'=>'ID', 'type'=>'raw', 'value'=>'$data->ID', ), array( 'name'=>'NAME', 'type'=>'raw', 'value'=>'$data->NAME', ),

CGridview conditional delete button

放肆的年华 提交于 2019-12-10 12:38:00
问题 I want the delete button to be active only in certain condition in CGgridView CButtonColumn (or make a custom delete button) e g if user=='admin' or status=='draft' . Any ideas? Thanks! 回答1: use 'visible' parameter - 'buttons'=>array ( 'delete' => array ( 'label'=>'Delete', //other params 'visible'=>!Yii::app()->user->checkAccess('admin'), ), 回答2: 'visible'=>'$data->status=="draft" || Yii::app()->user->checkAccess("admin")' 回答3: You can also use anonymous function if PHP >= 5.3 'visible'=