@@ -68,14 +68,22 @@ public function run()
6868 $ filterQuery
6969 ->offset (Yii::$ app ->request ->getQueryParam ('start ' , 0 ))
7070 ->limit (Yii::$ app ->request ->getQueryParam ('length ' , -1 ));
71+ /* Begin of fix - serverSide pagination - get pagination from server side - Yii
7172 $dataProvider = new ActiveDataProvider(['query' => $filterQuery, 'pagination' => false]);
73+ */
74+ $ dataProvider = new ActiveDataProvider (['query ' => $ actionQuery , 'pagination ' => ['pageSize ' => Yii::$ app ->request ->getQueryParam ('length ' , 10 )] ]);
75+ // End of fix - serverSide pagination - get pagination from server side - Yii
7276 Yii::$ app ->response ->format = \yii \web \Response::FORMAT_JSON ;
7377 try {
7478 $ response = [
7579 'draw ' => (int )$ draw ,
7680 'recordsTotal ' => (int )$ originalQuery ->count (),
77- 'recordsFiltered ' => $ actionQuery ->count (),
81+ 'recordsFiltered ' => (int )$ dataProvider ->getTotalCount (),
82+ /* Begin of fix - get actual data from server according to filters, offset and limit
7883 'data' => $dataProvider->getModels(),
84+ */
85+ 'data ' => $ actionQuery ->all (),
86+ // End of fix - get actual data from server according to filters, offset and limit
7987 ];
8088 } catch (\Exception $ e ) {
8189 return ['error ' => $ e ->getMessage ()];
@@ -96,6 +104,11 @@ public function applyOrder(ActiveQuery $query, $columns, $order)
96104 }
97105
98106 foreach ($ order as $ key => $ item ) {
107+ // Begin of fix - avoid failure on columns not being orderable
108+ if (array_key_exists ('orderable ' , $ columns [$ item ['column ' ]]) && $ columns [$ item ['column ' ]]['orderable ' ] === 'false ' ) {
109+ continue ;
110+ }
111+ // End of fix - avoid failure on columns not being orderable
99112 $ sort = $ item ['dir ' ] == 'desc ' ? SORT_DESC : SORT_ASC ;
100113 $ query ->addOrderBy ([$ columns [$ item ['column ' ]]['data ' ] => $ sort ]);
101114 }
0 commit comments