yii cgridview How to disable button

844 Views Asked by At

I know template or visible attribute can make it display or not if I need to display the button but I just want to disable the button. How to make it work

 $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'customer-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
       'id',
       'first_name',
     ),
    'template'=>'{update}{delete}'
2

There are 2 best solutions below

1
Double H On

Try deleteButtonOptions and updateButtonOptions of CColumnButton as

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'customer-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        'first_name',
        array(
            'class' => 'CButtonColumn',
            'header' => 'Manage',
            'template' => '{update}{delete}',
            'deleteButtonOptions' => array(
                'disabled' => true
            ),
            'updateButtonOptions' => array(
                'disabled' => true
            )
        ),
    ),

));
0
Anurag Vaishnav On

Disable View, Edit and Delete button.

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'auction-bid-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'id',
        'name',
        array(
            'class'=>'CButtonColumn',
              'template' => '',
        ),      
    ),  
));