Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Sortable Column for those non-DataColumn? #1576
In Yii1 if the column is not specified in DataProvider, there will not be any filter and we could not sort the table based on this column as well.
But how about we add some variable like compare and filter
I post it here, so that i think that may be a sweet improvement in Yii2. Feel free to correct me, if i said anything wrong. Or we can implement a similar outcome by make some modification in Model instead of View?
I am apologized for my poor English.
to allow sorting and filtering your value has to be calculated in the database. if your model calculates it in afterFind() or similar way you are not able to filter or sort by that field anymore.
$query->select = 'SUM(price) AS subtotal';
You also need to declare a property in your AR class to hold the value after find.
Marked this issue as documentation to add description about the topics to the guide.
So you mean we do that inside Model via a SQL statement. Okay. That will work fine.
But is there any way to allow us make a logic columns on the fly, as long as we can define their relation with the primary key? Sorry, I don't have a clearly use case. I just imagine when we need to combine some data from external resources, And that part may not be done by either making a View or other SQL solution.
Or we can use afterFind() to do so as well? Anyway, It is just a suggestion. Whether is it make sense or not?