Yii CGridView Model Set Default Sorting Order

php, yii

Solution

I think problem is here

$criteria->order = "member_id DESC";

Just Remove this line and then add in

   return new CActiveDataProvider($this,array(               
            'criteria'=>$criteria,
            'sort'=>array(
                        'defaultOrder'=>'member_id DESC',
                    ),
        ));

hope it will be help you.

Problem

My Yii CGridView Sorting is not working this way when ``` public function search() { $criteria = new CDbCriteria; $criteria->order = "member_id DESC"; ``` When I click header menu in `CGridView` it is not working but when I remove ``` $criteria->order = "member_id DESC";` ``` sorting is working fine. I want to show records by default `order by member_id desc`.

Original source

Related problems