giova94
(Antonioni Giovanni9)
November 12, 2015, 9:51am
1
Hi everyone,
I’ve a question about the gridview widget.
There is a method called rowOptions which allows you to assign a class to a row if the record have a specfic value setted.
For example:
'rowOptions' => function($model){
if($model->condition == false){
return ['class' => 'error'];
}
}
Is there a way to display an action ,in the action column, depending on the value contained in a specific propriety of a record?
for example if $model->propriety == true i want to display all the action and if $model->propriety == false i want to display only the delete and update actions in the actions column.
Thanks for all the help
giova94
(Antonioni Giovanni9)
November 12, 2015, 10:21am
3
so should i implement the logic for display buttons by using the button propriety?
Button
auticxdi
(Mkungonda)
November 12, 2015, 10:23am
5
['class' => 'yii\grid\ActionColumn',
template' => '{yourAction}',
'buttons' => [
'yourAction' => function($url,$model){
if($model->value==2){
return '';
}else{
return Html::button( '<a href=""><i class="fa fa-sign-out"></i></a>',['value' => $url, 'class' => ''] );
}},
You mean something as above?
giova94
(Antonioni Giovanni9)
November 12, 2015, 10:31am
6
Very clear as answer thanks all for the help.
auticxdi
(Mkungonda)
November 12, 2015, 10:32am
7
Remember: when you are adding custom action to your actioncolumn you have to define yourself default view/delete/edit actions.