Created
March 2, 2017 17:40
-
-
Save opotemkin/3e37122f8e275efa011330d238415b96 to your computer and use it in GitHub Desktop.
Yii2 new ArrayDataProvider + setSort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first | |
$dataProvider = new ArrayDataProvider(['query' => $query]); | |
$dataProvider->setSort([ | |
'attributes' => [ | |
'time', | |
'total', | |
'average-price', | |
], | |
'defaultOrder' => ['time' => SORT_ASC] | |
]); | |
// second | |
$dataProvider = new ArrayDataProvider([ | |
'allModels' => $models, | |
'pagination' => false, | |
'sort' => [ | |
'attributes' => ['category', 'seq', 'duration', 'info'], | |
'defaultOrder' => [ | |
'seq' => SORT_ASC, | |
], | |
], | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment