How to yii do the sorting for a non-existent field?

Need to do sorting in gridView, but such a field where there is none. This column displays the status of the order, if the connected table does not need the record, a pending status, if you have the status processed. We need this in order to unprocessed orders were top of the table the GridView, and the rest were sorted by date.
July 9th 19 at 10:16
1 answer
July 9th 19 at 10:18
In the idea, added to the model of public property, the Ala public $some_status, then in the sample this property is write your calculated value and then you can use it to sort.

Here is an example of advanced query:
$query = ModelName::find()
 'COALESCE(SUM(outcome.value), 0) AS public_field_name'
 ->orderBy(['' => SORT_DESC]);

 $dataProvider = new ActiveDataProvider([
 'query' => $query,
 'pagination' => [
 'pageSize' => 100,
 'sort' => false
Where in the sample you can calculate and store values ?
'id' => $this->id,
// other attr
'Status' => 'blabla', <- here ?
PS: search model generirovanie gii - watson_Torphy commented on July 9th 19 at 10:21
: corrected answer, if briefly, then add ->select([]) to query or addSelect:

$query->addSelect(["*", "CONCAT(first_name,' ', last_name) AS full_name"])->one(); - burnice commented on July 9th 19 at 10:24

Find more questions by tags Yii