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.
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
?
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] 删除。
我来说两句