Home > Article > Backend Development > yii2 gridview whether to display a certain column case, yii2gridview_PHP tutorial
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.