This is a migrated thread and some comments may be shown as answers.

Assistance with sorting on 'computed' column

1 Answer 199 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 16 Apr 2013, 11:36 PM
I am using the grid control and having a problem where it is not sorting on a column that is being calculated.  Here's the relevant part of my controller, where I'm performing my LINQ query:

                             select new Models.ApplicationModels.CustomerModel
                             {
                                 CustomerID = instance.CustomerID,
                                 CustomerOrders = GetCustomerOrders(instance.CustomerID)
                             };

This all displays perfectly fine.  I can sort on CustomerID, but I can't sort on CustomerOrders.  I'm not doing anything special with the binding, just calling it the same way as CustomerID.  

How can I get this to sort properly?  Would it help if I moved the logic of GetCustomerOrders into a SQL function and made it a computed column there?  I should note that I'd like to be able to sort this across all Customer entities -- and I am looking at a lot of data (millions of rows).  If there is a better way of handling this I'm open to suggestions.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 18 Apr 2013, 02:43 PM
Hello Ian,

What exactly is happening when trying to sort on that field? I assume that an exception is thrown because the generated expression tree (after applying sorting/ filtering or grouping) contains that calculated field which could not be executed on the database level. 
Try to move the logic on a database level and share your findings.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Ian
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or