Do Not Display Cbuttons On Specific Row In Cgridview

Howdy folks,

This ones got me stumped, hope you can help!

I have a grid view populated by a CArrayDataProvider.

The view contains a primary row, and its sub rows.

I want to display a button only one the sub rows.

The button view currently looks like this:




array(

  'header' => '<span title="Actions">Actions</span>',

  'class'=>'CButtonColumn',

  'template'=>'{remove}',

    'buttons'=>array(

        'remove' => array(

	   'label'=>'Remove this item from this group',     

	   'url'=>'Yii::app()->createUrl("controller/action", array("id"=>$data["id"]))',

	   'imageUrl'=>Yii::app()->request->baseUrl.'/images/icon/Remove.png',

	   'options'=>array('title'=>'Remove this item from this group'), 

	),

    ),

),



What I’d like to include is something along the lines of:




if($data['id'] == $Yii::app()->session['primaryId']) { Don't display the button }



So basically display the button on all the rows in CGridView except the 1 row that matches the primary ID.

Is there a way to do this?

Thanks!

CButtonColumn::$buttons


'visible'=>'...',   // a PHP expression for determining whether the button is visible

Thanks Tsunami!

That did the trick :)




'visible'=>'$data["id"] != Yii::app()->session["primaryId"]',



Hi,

you can write a ternary operator (if condition) on admin grid view…

e.g


'value' => '($data["active"] == 1 ? " ":"abc")',