-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Sortable Column for those non-DataColumn? #1576
Comments
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? |
docs are quite clear about this. |
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.
example. we have a column called Subtotal in Quotation_Item gridview.
it may looks like this
But how about we add some variable like compare and filter
E.g.
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.
The text was updated successfully, but these errors were encountered: