Home  >  Article  >  Backend Development  >  yii2 gridview whether to display a certain column case, yii2gridview_PHP tutorial

yii2 gridview whether to display a certain column case, yii2gridview_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:53:53695browse

Whether yii2 gridview displays a certain column of cases, yii2gridview

Author: Bailang Source: http://www.manks.top/article/yii2_gridview_visible

The copyright of this article belongs to the author, and you are welcome to reprint it. However, this statement must be retained without the author's consent, and a link to the original text must be provided in an obvious position on the article page. Otherwise, we reserve the right to pursue legal liability.

Let’s take a simple case

Condition: There is a get parameter type

Requirement: The column name will be displayed only when the value of type is equal to 1, otherwise the column will not be displayed

The code is implemented as follows:

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

The implementation method is also very simple.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1122768.htmlTechArticleyii2 gridview Whether to display a certain column of cases, yii2gridview Author: Bailang Source: http://www.manks.top /article/yii2_gridview_visible The copyright of this article belongs to the author. Reprinting is welcome, but without authorization from the author...
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