Answer the question
In order to leave comments, you need to log in
Is it possible to set the columns in some way through the Yii2 Gridview parameter?
Tell me please! I send an Ajax request to the controller, depending on the parameter, the controller accesses the corresponding model, respectively, the columns change when the gridview is displayed. Is it possible to set a condition, in Gridview, so that the choice of columns depends on the selected model.
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute'=>'sid',
'label' => 'Номер отправки',
],
[
'attribute'=>'ts',
'label' => 'Время',
],
]
Answer the question
In order to leave comments, you need to log in
Of course you can. Columns are an array. You can form an array as you like and pass it to the widget as a variable.
In some cases, this may be a method in the model, for example, in the search model.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question