Hello,
I have ever made something like this before and here is how I made it works.
In the relation:
return array(
'distributor' => array(self::BELONGS_TO, 'Distributor', 'distributor_id'),
);
In search procedure:
// set sort options
$sort = new CSort;
$sort->attributes = array(
... (the other fields)
'distributorName'=>array(
'asc'=>'distributor.name',
'desc'=>'distributor.name desc',
),
);
$sort->defaultOrder = 'distributor.name';
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
'sort'=>$sort,
));
And in CGridView:
array(
'name'=>'distributorName',
'value'=>'$data->distributor->name',
)
Not sure if this is the best solution, but hopefully this can give a click to you.