In order to sort Yii CSqlDataProvider you have to pass CSort() object to it.
1 2 3 4 5 6 7 8 9 10 11 |
$sort = new CSort(); $sort->attributes = array( 'id' => array( 'asc' => 'table.id', 'desc' => 'table.id DESC' ), 'value1' => array( 'asc' => 'table.value1', 'desc' => 'table.value1 DESC' ) ); |
In case the CSqlDataProvider is not sorted you should probably check your query passed to the object. Pay attention not to add a semicolon at the end of your query.
1 2 3 4 5 6 7 8 9 |
$query = "SELECT * FROM table1"; $dataProvider = new CSqlDataProvider($query, array( 'totalItemCount'=> $count1, 'sort' => $sort, 'params' => array(), 'pagination' => array( 'pageSize'=> 300 ) )); |





