Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
For example, you can put all the columns in a variable and, depending on the condition, add or remove.
$columns = [
// coulumns
];
if($condition) {
$columns[] = $someColumn;
}
GridView::widget([
'columns' => $columns,
// ...
]);
Each column has a parameter visible
. If it false
is , then the column is not displayed. For example:
GridView::widget([
'columns' => [
[
'attribute'=>'column_name',
'visible'=> boolval($condition)
],
// ...
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question