I have a model with a virtual (calculated) column which I need to make sortable in admin’s CGridView. I have created a new CSort object with required SQL statements. Now if I add the sort object into CActiveDataProvider:
new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'sort' => $sort,
));
I got the grid with only this one column sortable, but all the others looses the sorting option. I understand that I can make them sortable by adding them to my custom CSort object, but this is counterproductive because requires to duplicate names of the fields, and keep an eye on this portion of code to be synchronized with other columns, which may be added in the future.
So the question is - how to add custom sorting attributes to default ones, which CActiveDataProvider provides for db columns?
I have tried the following: first - create CActiveDataProvider $result without the ‘sort’ attribute, and second - merge arrays: