3

I have two tables with farily same names of the columns, usinng two different search models (both using ActiveDataProvider's) so when I sort one by a column, the other gets affected as well.

I have tried setting this in my second GridView:

'sorter' => [
    'class' => 'yii\widgets\LinkSorter',
    'sortParam' => 'sortB',
],

But with no avail.


EDIT: Sort param is a GET variable passed to server: ?sort=amount, or ?param=1&sort=created_at.

Zlatan Omerović
  • 3,863
  • 4
  • 39
  • 67

1 Answers1

5

$sortParam is a property of yii\data\Sort, which handles the sorting on the DataProvider level and is accessable via $dataProvider->sort. The $sorter on the GridView is only a widget that can display the sorting links, but that is inherited from BaseListView and not displayed in GridView by default.

You should set this property on the DataProvider like this:

$dataProvider->sort->sortParam = 'user-sort';

The same applies to the pageParam too. There is a section in the guide about Multiple GridViews on one page covering exactly this topic.

cebe
  • 3,610
  • 1
  • 23
  • 37