Tuesday, 10 February 2015

Yii2 Dataprovider Default Sorting


To set the default sorting for Yii2 Data provider is

    $dataProvider = new ActiveDataProvider([
         'query' => $query,
         'sort'=> ['defaultOrder' => ['id' => 'DESC']]

     ]) 


    ( or )


   $dataProvider->sort = ['defaultOrder' => ['id' => 'DESC']];