Sort and filter data in GridView Yii2 where column is not in database

后端 未结 3 588
孤独总比滥情好
孤独总比滥情好 2020-12-28 23:38

If I have 2 fields in db - probability and influence and I need a column in GridView where these two fields are multiplied. I managed to add it there like:

          


        
3条回答
  •  难免孤独
    2020-12-29 00:03

    Here is my solution, which works for sorting non-table field

         $dataProvider->sort->attributes['customer'] = [
            'asc' => ['customer' => SORT_ASC],
            'desc' => ['customer' => SORT_DESC],
        ];
    

提交回复
热议问题