Home  >  Article  >  php教程  >  yii2 gridview 是否显示某列案例 - 白狼栈

yii2 gridview 是否显示某列案例 - 白狼栈

WBOY
WBOYOriginal
2016-05-20 11:39:35843browse

作者:白狼 出处:http://www.manks.top/article/yii2_gridview_visible

本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

我们举一个简单的案例

条件:有一个get形参数type

需求:仅且type的值等于1的时候,列name才显示,否则该列不显示

代码实现如下:

[
    'attribute' => 'name',
    'value' => $model->name,
    'visible' => intval(Yii::$app->request->get('type')) == 1,
],

 

实现方式也是很简单滴。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn