Hide The Buttons For Cbuttoncolumn In Cgrid View

hi,all,

i want to hide the buttons for cbuttoncolumn in cgrid view for condition where id=1.

my code

‘visible’=>’$data->id=1’,

this not working…any idea?

You’re using the assignment operator instead of equality. Change = to ==.

yes i change = to == but no result.

my code

array(

		'class'=>'CButtonColumn',


		'header'=>'Actions',


		'visible'=>'$data->id==1',


		





	),

‘visible’ is not evaluated for every row - it only says whether whole column should be visible or not: http://www.yiiframework.com/doc/api/1.1/CGridColumn#visible-detail

in your case - not empty string ‘$data->id==1’ is simply treated as ‘true’ and it does not matter what you put in it.

Thanks for you reply.

yes i changed the code from ‘$data->id==1’ to ‘$data’->id==1,. so in result cbutton columns is disappear.

So what code i should use for making the row of buttons coums hide if there is id=1.??

thanks again…

You could use cssClassExpression to apply a class to the column when you don’t want to display the cell. You’d have to set the css for that class to display:none;

What you’re doing with the visible attribute is incorrect. You should probably remove that attribute from your configuration.

how it be possible…can u little bit help for code…?

thanks

In column config:




'cssClassExpression'=>function($data){

    return $data->id == 1 ? 'hidden-buttons' : '';

},



In your css:




.hidden-buttons { display:none; }



Sir,i used above code in array as

array(

		'class'=>'CButtonColumn',


		'header'=>'Actions',


		


		'cssClassExpression'=>function($data)


		{    return $data->id == 1 ? 'hidden-buttons' : ''; },


		


		





	),

but there is error on page "Trying to get property of non-object ".plz see this thanks