yii2-widget-datatables
yii2-widget-datatables copied to clipboard
defaultOrder being ignored by DataTables
I have the following in the model's search method:
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => ['defaultOrder' => ['id' => 'DESC']],
]);
This works fine with GridView::widget but seems to be ignored by DataTables. Is this a known problem? I'm having trouble finding the cause.
In view index.php... add in clientOptions "order"=>[[column,"type"]] example:
= DataTables::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'clientOptions' => [ // "lengthMenu"=> [[20,-1], [20,Yii::t('app',"All")]], "info"=>true, "responsive"=>true, "order"=> [[ 2, "desc" ]]