CGridView sorting

In a GridView I have a column displaying values of a related model like:


and I want to know how I can sort by this column? The column header isn’t a link :( Seems like only properties of the main model itself get a link in column header.

try to define (for CActiveDataProvider)

'sort'=>array('attributes' => array(

  'myColumnName' => array(



    'desc'=>$expr.' DESC',










thanks for your reply. I’ve tried to use your suggested code, but I got an error. What does “$expr” stands for?

I accomplished this slightly differently. See the post where I detailed it.