Page 1 of 1
CGridView default sort
#1
Posted 05 April 2010 - 08:32 AM
How can I specify the CGridView default sort?
I want that as soon as the page finishes loading, the grid should be sorted alphabetically by a specific column.
Of course the user can later change that order by clicking in the column headers.
I want that as soon as the page finishes loading, the grid should be sorted alphabetically by a specific column.
Of course the user can later change that order by clicking in the column headers.
#4
Posted 11 October 2010 - 06:32 AM
Hello,
I can add default sort column to my CGridView, but the default sort icon does not display on column header.
Can anyone help me?
Thanks
I can add default sort column to my CGridView, but the default sort icon does not display on column header.
Can anyone help me?
Thanks
#5
Posted 15 July 2011 - 03:54 PM

POPULAR
Ho Khac Huy, on 11 October 2010 - 06:32 AM, said:
Hello,
I can add default sort column to my CGridView, but the default sort icon does not display on column header.
Can anyone help me?
Thanks
I can add default sort column to my CGridView, but the default sort icon does not display on column header.
Can anyone help me?
Thanks
I just ran into this same issue, and will document the solution here in case anyone else is searching the forums for a solution. As of version 1.1.3, you can make defaultOrder an array, which will in turn populate the directions property, which will make the arrow direction indicator icons show up like you want:
$dataProvider=new CActiveDataProvider('Example', array(
'sort'=>array(
'defaultOrder'=>array(
'title'=>false
)
)
));The value of the column name key indicates direction - false for ASC, true for DESC.
#6
Posted 05 July 2012 - 11:57 AM
Matt Kelliher, on 05 April 2010 - 08:29 PM, said:
In your data provider, you can use the "defaultOrder" property of CSort. For example:
$dataProvider=new CActiveDataProvider('Example', array(
'sort'=>array(
'defaultOrder'=>'title ASC',
)
));
This solved my problem. Thanks!
#7
Posted 13 July 2012 - 01:06 PM
mcnecessary, on 15 July 2011 - 03:54 PM, said:
I just ran into this same issue, and will document the solution here in case anyone else is searching the forums for a solution. As of version 1.1.3, you can make defaultOrder an array, which will in turn populate the directions property, which will make the arrow direction indicator icons show up like you want:
The value of the column name key indicates direction - false for ASC, true for DESC.
$dataProvider=new CActiveDataProvider('Example', array(
'sort'=>array(
'defaultOrder'=>array(
'title'=>false
)
)
));The value of the column name key indicates direction - false for ASC, true for DESC.
Thanks - I was scratching my head over getting the order arrows to display on page load. Note that from version 1.1.10, the constants CSort::SORT_ASC and CSort::SORT_DESC are available for convenience/readability.
#8
Posted 25 March 2013 - 08:09 AM
there is no need to complicate, just:
$model=new YourModel();
$model->dbCriteria->order='title ASC';
shakedbrains this!
$model=new YourModel();
$model->dbCriteria->order='title ASC';
shakedbrains this!
Share this topic:
Page 1 of 1

Help














