Yii2 grid view widget sorting in desc order -


i have grid view

 <?= gridview::widget([         'dataprovider' => $dataprovider,         'columns' => [             ['class' => 'yii\grid\serialcolumn'],               'movie.movie_name',             'start_date',             'end_date',             'theatre.theatre_name',             'screen.screen_name',             'time.start_time',              ['class' => 'yii\grid\actioncolumn'],         ],     ]); ?> 

how can arrange them in descending order based on start_date?

in search model add sort attribute:

public function search($params) {     ...      $dataprovider = new activedataprovider([         'query' => $query,         'sort'=> ['defaultorder' => ['start_date' => sort_desc]]     ]);  .... } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -