By Default Sort Desc Instead Of Asc In Cgridview

Hi all,

as you know cgridview sort a column ASC in first and in second click, sort will change to DESC.

I want to reverse that,

I want first click, sort the column DESC and second click, sort the column ASC.


thanks :)

See - this person has som issues, but the example should inspire you.

Hi, Brother, I am glad to help you.

You need to set in your dataprovider, exactly in sort options set this

    'dataProvider'=>new CActiveDataProvider('SomeModel', array(









Hope you will thank me.

Nurbek Nurjanov, Yii developer

Use in your model,

return new CActiveDataProvider($this, array(


                        'sort'=>array("defaultOrder"=>"task_id DESC")