A
A
AlexSer2018-07-03 07:30:51
Yii
AlexSer, 2018-07-03 07:30:51

How to display data in reverse order in Gridview Yii2?

I deduce the data in Grivdview And how to make that displayed the data upside-down. Starting from latest to 1 by date, without clicking on the filter.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-07-03
@AlexSer

In the Search model in the dataProvider you need to add:

$dataProvider = new ActiveDataProvider([
  'query' => $query,
  'sort' => [
    'defaultOrder' => ['created_at' => SORT_DESC],
  ],
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question