CButtonColumn different for rows in CGridView

Hello, I would like to use CGridView and CButtonColumn, the buttons should be different for each row conditioned by the data in the row.

So I could have in the first row "Show Update Delete" in the second only "Show" and so on…

Is this possible?

thanks

Maybe by attaching a behaviour to CDataColumn you could change the buttons template for each row

I replayed you in this post:

http://www.yiiframework.com/forum/index.php?/topic/7358-cbuttoncolumn-different-in-cgridview-from-row-to-row-depending-on-data-in-single-rows/page__hl__cbuttoncolumn__fromsearch__1

Hello,

thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.

By the way, which is the function of the property visible from CButtonColumn class? Because for me it don’t work or I don’t know how to use it.

Note that this extension is better suited for the need to have different buttons in different rows… if you want to omit the update button in all rows than it is faster to just set the template property - http://www.yiiframework.com/doc/api/CButtonColumn#template-detail

the visible property is for the custom buttons - http://www.yiiframework.com/doc/api/CButtonColumn#buttons-detail

I resolved this problem like below:

In this example visibility of delete button depends on result of function CzyTypJestDowiazany().

CGridViewVidget :

$this->widget(‘zii.widgets.grid.CGridView’, array(

‘id’=>‘typy-grid’,

‘dataProvider’=>$DataProvTU,

‘columns’=>array(‘nazwa’,

   array('class'=>'CButtonColumn', 


     'htmlOptions'=>array('style'=>'float:left;'),


 'template'=>'{update}          {delete}',


 'buttons'=>array(


 'deleteButtonVisible'=>'User::canDelete($data->id)',


 'delete'=>array('url'=>'CController::createUrl("/typyUzytkownikow/delete",array("id"=>$data->primaryKey))', 


     	[b]         'visible'=>'CzyTypJestDowiazany($data->id)',  [/b]   	     


        ), 


         ),		              


  ),


  ),

));

And now function CzyTypJestDowiazany. You can put it in Controler or in some other file included in index.php.

function CzyTypJestDowiazany($id_typu){

// Put Your code here …

// whatever you want

// and return false or true depend of result of your code.

if ($RESULT) {return true;}

else {return false;}

}