For example here is my search function for CGridView:
public function search1()
{
$criteria=new CDbCriteria;
$criteria->condition='enquiry_id=:enquiry_id AND received = 1';
$criteria->params=array(':enquiry_id'=>$_GET['id']);
$criteria->order="supplier_price";
$criteria->compare('supplier_id', $this->supplier_id);
$criteria->compare('received_at', $this->received_at, true);
$criteria->compare('supplier_price', $this->supplier_price);
$criteria->compare('our_price', $this->our_price);
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
As you can see I specified $criteria->order to specify a "default" sort order - which works fine, however when I sort on the columns in CGridView the sorting does not work - I assume this is because my order declaration is acting as a global sort.