계산 된 열이 있습니다. 정렬 가능하고 싶습니다. 나는 그것을 위해 get 메소드를 가지고 ...Yii Sortable Column in CGridView
public function getCur_margin() {
return number_format(($this->store_cost/$this->store_price)/$this->store_cost * 100, 2) . '%';
}
그리고 나는이 스레드를 따라 ...
CGridview custom field sortable
을하지만 지금은 데이터베이스의 실제 열을 찾고. <calculations> AS cur_margin
을 사용하여이 CActiveDataProvider에 대해 일시적으로 필드를 가져올 수 있습니까?
$dataProvider = new CActiveDataProvider('Products', array(
'criteria' => array(
'condition' => 'store_id IN (SELECT `id` FROM `stores` WHERE `user_id` = ' . Yii::app()->user->id . ')',
),
'pagination' => array(
'pageSize' => 15,
),
'sort'=>array(
'attributes'=>array(
'cur_margin' => array(
'asc' => 'cur_margin ASC',
'desc' => 'cur_margin DESC',
),
),
),
));
도움이 될 수 있습니다. http://www.mrsoundless.com/php/yii/searching-and-sorting-a-column-from-a-related-table-in-a-cgridview/ – MrSoundless