Search code examples
sortingyiicgridview

Yii sort OR order CGridView by 2 or more columns


So I have a table which consist of Date, Time Start, Time End, Client.

How can I sort the table in a way such that it orders by Date ASC and then looks into Time Start ASC.

I tried adding these 2 lines in actionAdmin of the controller.php:

$model->dbCriteria->order='date ASC'
$model->dbCriteria->order='timeStart ASC

But it will ignore the Date sort and goes directly into timeStart sorting.

How can I do it so that it takes both into account? Please advise, thanks.


Solution

  • CDbCriteria does not provide multi-sort feature. If you need to have multi-sort, you should use other third-party plugins such as jqGrid.