Action Columns

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

You could config the ActionColumn adding this button.

http://www.yiiframework.com/doc-2.0/yii-grid-actioncolumn.html

so should i implement the logic for display buttons by using the button propriety?

Button

Exactly


['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?

Very clear as answer thanks all for the help.

Remember: when you are adding custom action to your actioncolumn you have to define yourself default view/delete/edit actions.