Rule to display the buttons on the grid

In all my list screens have a grid with three action buttons: view, edit, delete.

In some of these screens, need to implement a control to display the buttons according to control permission per item

For example, the user can only edit the item that it owns. Then the edit button does not appear on the items that he is not the owner (or a button appears disabled).

Can someone help me make a suggestion which way to go for implementation?

I could use the template, but it goes for the whole grid, not for each individual item.

You can use the ‘visible’ property of the CButtonColumn with a PHP expression, something like this;




     ...

    'class'=>'CButtonColumn',

     ...

     'buttons'=>array(

            'view'=>array(

               'visible'=>'Yii::app()->user->checkAccess("read") ? true : false',

            ),

             'update'=>array(

               'visible'=>'$data->owner == Yii::app()->user->id',

            ),




Thank you very much!