bitmatix
(Bitmatix)
March 30, 2010, 7:15am
1
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.
vamp
(Vamphouse)
March 30, 2010, 7:41am
2
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")',
),
...
bitmatix
(Bitmatix)
May 6, 2010, 1:49pm
3
vamp:
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.