Answer the question
In order to leave comments, you need to log in
How to make such sorting in yii2 ActiveDataProvider?
Hello, tell me how you can make such sorting, it turns out reverse sorting ?sort=-id
, only mirrored on the pages, example:
Страница 1:
8
9
10
Страница 2:
5
6
7
Страница 3:
2
3
4
Страница 4:
1
Answer the question
In order to leave comments, you need to log in
Just pass the desired query to the dataProvider, with sort by id in reverse order, and then reverse the array ( php.net/manual/ru/function.array-reverse.php), which will give the getModels () method in activeDataProvider.
getModels() returns only the models for a particular page, so this is something you have to play with.
It's probably more beautiful to do this by creating your own DataProvider, inheriting from activeDataProvider and overriding getModels() there;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question