pdwjun
pdwjun

Reputation: 133

yii cgridview How to disable button

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}'

Upvotes: 0

Views: 860

Answers (2)

Anurag Vaishnav
Anurag Vaishnav

Reputation: 11

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' => '',
        ),      
    ),  
));

Upvotes: 1

Double H
Double H

Reputation: 4160

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
            )
        ),
    ),

));

Upvotes: 2

Related Questions