Answer the question
In order to leave comments, you need to log in
How to implement column sorting in gridView added from linked table in Yii2?
How to implement column sorting in a GridView that is added from a related table. All columns are sorted except this one. Please be consistent: what needs to be added to the Controller, what to the Model ..
Answer the question
In order to leave comments, you need to log in
in the data provider, you need to specify data on how to sort this attribute, for example:
$dataProvider->sort->attributes['author.name'] = [
'asc' => ['author.name' => SORT_ASC],
'desc' => ['author.name' => SORT_DESC],
];
in index.php in GridView
in the example below, the connection with City by the city_id field
[
'attribute' => 'city_id',
'filter' => City::find()->select(['name', 'id'])->indexBy('id')->column(),
'value' => ...
]
Specify a property in the search model, and dance from it in search().
Specify this parameter in DataProvider in sort
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question