Yii2 Hide Actions in Action Column of a Single Row only

kaynewilder

I have a GridView and some of the items in the list are not created by the user, but they are pre-defined buy us, the developers.

enter image description here

In the image above, the row with the (not set) Store ID is the pre-defined item we created. Since it is pre-defined, it should not have the Action Icons "view", "update", and "delete".

How do we, at least, hide these action icons on our pre-defined items in the GridView?

vitalik_74

You may create new column and set callable $content property. See http://www.yiiframework.com/doc-2.0/yii-grid-column.html#$content-detail

So, for example. Put this code in Grid columns:

[        
    'content' => function ($model, $key, $index, $column) {
        if ($model->storeId == null) {
            return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['view', 'id' => $model->id])
            . Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['update', 'id' => $model->id])
            . Html::a('<span class="glyphicon glyphicon-trash"></span>', ['delete', 'id' => $model->id], ['data-method'=> 'post']);
        }
    }
]

This is work in my project like that https://yadi.sk/i/2fWnWZBNffQJL and https://yadi.sk/i/GyHWD9m9ffQK2

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

yii2 bootstrap modal hide show

来自分类Dev

Yii2中的Ajax + Controller Action

来自分类Dev

Equivalent of "Yii::app()->runController('controller/action')" in Yii2?

来自分类Dev

disable a css only for one layout yii2

来自分类Dev

Actions not showing in android action bar

来自分类Dev

是否等效于Yii2中的“ Yii :: app()-> runController('controller / action')”?

来自分类Dev

Yii2需要所有Controller和Action才能登录

来自分类Dev

通过action()指定Yii2控制器中的动作请求动词

来自分类Dev

Rest ActiveController Yii2中具有id的Action中的自定义操作

来自分类Dev

在2D数组中a [row] [column] a [row]代表什么?

来自分类Dev

Github action actions / checkout @ v2 lfs:true标志不会将指针转换为实际文件

来自分类Dev

Even though I have 2 dedicate HttpGet Actions defined in my controller, only one gets called even when the URL specifies 2 different Actions

来自分类Dev

Column/Row index in a DataGrid column

来自分类Dev

Column to row in pandas dataframe

来自分类Dev

$ row ['column']在PHP中

来自分类Dev

从CSV读取值并以Column1:Row1,Column2:Row1格式输出

来自分类Dev

Hide span in second table row through jQuery

来自分类Dev

Struts2 Only Use specific Variable Object for JSON Result(不是所有的Action变量)

来自分类Dev

Yii2认证

来自分类Dev

Yii2 DatePicker

来自分类Dev

Yii2翻译

来自分类Dev

Yii2 attributeLabels()

来自分类Dev

Yii2认证

来自分类Dev

YII2拖放

来自分类Dev

Yii2 compareValidator 当

来自分类Dev

Google Charts hide only some series in legend

来自分类Dev

how to hide nav bar on first view only

来自分类Dev

How to hide a column in devexpress gridview on page load?

来自分类Dev

rating bar not show all star in single row

Related 相关文章

热门标签

归档