CGridView sorting

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


objRelated.strName:text:Name

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(

    'label'=>'NAME',

    'asc'=>$expr='CUSTOM_SQL_EXPRESSION_TO_APPLYING',

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

  ),

  ...);




then:


 $columns=array(

   array(

     'name'=>'myColumnName',

     'value'=>'CHtml::value($data,"my.related.property.name")',

   ),

   ...

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.