How to disable cgridview view button or setting visiability to false

Coder picture Coder · Jun 22, 2012 · Viewed 12.8k times · Source

can some buddy please suggest how to disable view button on cgridview widget and how to add more button like active..

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'customer-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
       'id',
       'first_name',
           'last_name',
       'club.club_name',
       array(
         'class' => 'CButtonColumn',
                     'updateButtonUrl' =>'Yii::app()->createUrl("/customer/editmember1",array("id" => $data->primaryKey))',
                     'updateButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/edit.jpg',
                     'deleteButtonUrl' =>'Yii::app()->createUrl("/customer/delete",array("id" => $data->primaryKey))',
                     'deleteButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/delete.jpg', 
                     'viewButton' => array('visiable' => false), 
            ),

              ),   
               )); 

Answer

sucotronic picture sucotronic · Jun 22, 2012

Use the 'template' property do show only your desired buttons:

'class' => 'CButtonColumn',
           'template' => '{update}{delete}',
                 'updateButtonUrl' =>'Yii::app()->createUrl("/customer/editmember1",array("id" => $data->primaryKey))',
                 'updateButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/edit.jpg',
                 'deleteButtonUrl' =>'Yii::app()->createUrl("/customer/delete",array("id" => $data->primaryKey))',
                 'deleteButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/delete.jpg', 
        ),