Disable Delete button Disable default delete button
Posted 12 February 2016 - 04:11 AM
In CGridview, I want to disable "Delete" button for some rows based on condition. I don't want to hide Delete button. Just want to disable it, so user can view delete button but can not click on that button. If user status is 'ACTIVE' at that time only Delete button will be Enable and user can click on it.
Thank in Advance !!
Posted 12 February 2016 - 04:25 AM
I can use 'Visible' property but it will hide the button and I don't want it. If I use 'htmlOptions', in that I can not put conditions for each row. Can you please explain in detail or if possible plese give example.
Posted 12 February 2016 - 05:20 AM
Posted 12 February 2016 - 06:13 AM
Thank you for the Reply, But still I am not getting proper solution. CSS class is applying for entire row, not for a single button or column. If I make it readonly, it will apply to row and whole row is now readonly including update and delete button. As I want to apply CSS only on Delete Button.
Posted 13 February 2016 - 12:09 AM
With Delete button, I wrote new attribute as :
'checkdisable' => '$data->spn_status == Yii::app()->params["statusInUse"] ', (It must return either true or false)
In framework/zii/widgets/grid/CButtonColumn.php file --> After 342 line put this code (in protected function renderButton()) :
if(isset($button['options']['checkdisable']) && $this->evaluateExpression($button['options']['checkdisable'],array('row'=>$row,'data'=>$data)))
$button['options']['disabled'] = true;
Hope it can be usefull for others.
Thank you All for your suggestions.