0
votes

In yii project i am using listview to display data in table view.

Sorting option working for existed database colums.

Now i want to display relation values in list view. Those values i am getting from relations. Like:

 'noOfImages'=>array(self::BELONGS_TO,'Images','user_id')

Now how to add sorting for 'noOfImages' column.

 <td><?php echo CHtml::encode($model->noOfImages); ?></td>    

In the above code 'noOfImages' is not a db column . it's an calculated value through relations of that model.

Thanks in Advance.

1

1 Answers

0
votes

To access the property add public $noOfImages to your model. Sure you can do calculations you need(for example in afterFind method)