Hi,
Is there any way to disable or set the visibility of checkbox in ccheckboxcolumn in cgridview to false based on certain conditions?
I’ve been searching in the internet but couldn’t find any solutions to it.
Hi,
Is there any way to disable or set the visibility of checkbox in ccheckboxcolumn in cgridview to false based on certain conditions?
I’ve been searching in the internet but couldn’t find any solutions to it.
Hello, have you tried the ‘visible’ property of the CCheckBoxColumn class?
I’ve tried inserting the code (‘visible’=>’$data->status==“accept” ? true : false’,) as shown below but the checkbox still displays even when the status is “reject” instead of “accept”.
Is there anything wrong with the code?
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'my-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'id'=>'autoId',
'class'=>'CCheckBoxColumn',
'header'=>'',
'selectableRows'=>'2',
'visible'=>'$data->status=="accept" ? true : false',
),
),
));
As you see in this topic, ‘visible’ property doesn’t accept PHP expression.
You can make use of ‘cssClassExpression’ property instead.
array
(
'id'=>'autoId',
'class'=>'CCheckBoxColumn',
'header'=>'',
'selectableRows'=>'2',
'cssClassExpression'=>'$data->status=="accept" ? "" : "hidden"',
),
And somewhere in your css file:
.hidden {
display: none;
}
Thanks a lot!