Hi,
I have a problem sorting my list (from a related table) in CListView.
From views/place/view.php,I would like a display all the locations related to a place.
I’m able to list the locations but unable to sort by location name. Please help. Thanks
My tables are as follows:
+-------+ +------------+ +--------+
|place | | outlet | |location|
+-------+ +------------+ +--------+
| | |id | | |
|id |-----<|placeID | +--|id |
|name | |locationID |>-+ |name |
+-------+ +------------+ +--------+
My code is as follows:
$condition="placeID ='$model->id'";
$criteria->condition=$condition;
$criteria->order = 'id';
$dataProvider= new CActiveDataProvider('Outlet',array(
'criteria'=>$criteria,
'pagination'=>array('pageSize'=>30),
));
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_viewoutlet',
'enableSorting'=>'true',
'sortableAttributes'=>array(
'locationID', //what do I need to insert to sort by location name instead of locationID?
),
));