Dear Ian.T
This is what I found some thing useful.Though it is not a better solution.
For CArrayDataProvider:
If column value is null, we are going to give a massive number
that is greater than maximum value in the column.
When page loads we are going to get the display in ascending order with null values at bottom.
When we click the sorter, we are going to get default order in the table or
descending order with null values at bottom.
public function search()
{
$criteria=new CDbCriteria;
.........................
.........................
$criteria->order="IFNULL(column_name,10000000) ASC";//some big value that is beyond the scope.
.................................................
................................................
$objects=AR::model()->findAll($criteria);
return new CArrayDataProvider($objects,array(
'sort'=>array('attributes'=>array('attributeName'=>array('desc'=>'column_name DESC')))
));
}
For CActiveDataProvider:
Here we can
not apply the
order beforehand in CDbCriteria.
public function search()
{
$criteria=new CDbCriteria;
.........................
.........................
/// $criteria->order="IFNULL(column_name,10000000) ASC"; This makes the sorter inactive.
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort'=>array('attributes'=>array('attributeName'=>array('asc'=>'IFNULL(column_name,10000000) ASC','desc'=>'column_name DESC')))
));
}
I hope there are better solutions to this.
Regards.