I know that the webapi data source is being called, and returning a PageResult with a valid count and records. However, the grid doesn't show any data. What am I missing? I can send a sample project if it will help.
I think I found something... there's an exception returned from the webapi "get" call.
It would seem that there are differences in the linq aupport between Entity Framework and using linq to sql directly, as the sample you provided does. Since "OrderBy" isn't called if the incoming query doesn't ask for it, the call to "skip" fails.
I've worked around it (for now) by setting a default "order by" if the query isn't asking for one. Is there a way at the view level to set the default sort order for a grid, so I don't have to make that assumption in the webapi code?
Exception thrown: 'System.NotSupportedException' in EntityFramework.dll ("The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.")
SSSeeni Sakthi Kumar Seeni Raj Syncfusion Team November 11, 2016 12:29 PM UTC
In case, no sorting request has been initiated at the Grid end, the OrderBy query options will not be available at the server-end. Therefore, we can handle this by checking some conditions as shown below. And there is no need to initiate the sorting from the client-end to handle these kind of typo. Since you can handle them at the server end by checking whether the OrderBy is null or not.
So we would like to handle the OrderBy or any other query using above code example. If you are still facing any issue, please share the information requested in our last update. If you could have provide the code example of your code behind/api controller, which would be helpful to inspect the issue and provide the solution as soon as possible.
Seeni Sakthi Kumar S.
RBR Brian LindahlNovember 11, 2016 10:29 PM UTC
I have very similar code in my data controller. I have added an "else" on the "if (opts.OrderBy == null)" to provide a valid OrderBy clause in the query. Without it, an EntittyFramework dbSet will not accept the "opts.Skip" clause. My question is, is there a way in the grid declaration to specify the default sort order for the grid? I have .allowSorting set, but until I click on a column header, it won't send an orderBy clause.
RURagavee U S Syncfusion Team November 14, 2016 06:38 AM UTC
Yes. We can perform initial sorting in grid using the SortedColumns property of the Grid. Please refer to the below online documentation link where we have discussed on the initial sorting concept.