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

RadGridView, Paging, QueryableCollectionView & EntityFramework

2 Answers 242 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Koen
Top achievements
Rank 1
Koen asked on 18 Sep 2013, 07:19 AM
Hello All,

I'm trying to setup the following scenario, running version 2013.2.724.40:
  • On my ViewModel, I have a QueryableCollectionView, with an EntityFramework IQueryable as it's source
  • I have a DataGrid, bound to this QueryableCollectionView
  • I have a DataPager, linked to this DataGrid

<telerik:RadGridView x:Name="radGridView"
         ItemsSource="{Binding MyQueryableCollectionView}"
         AutoGenerateColumns="True" />          
<telerik:RadDataPager
         Source="{Binding Items, ElementName=radGridView}"
         PageSize="10" DisplayMode="All" />

When I run this app, everything looks fine:
  • A query is ran on the db, selecting the top 10 records for the first page
  • The DataGrid shows the first page, 10 records
  • The DataPager calculates the correct number of pages

However, when I move to the second, third, .. page, the page is empty.
No new query is ran on the db to select the next 10 records.

Is this kind of scenario not supported out of the box?



Notes:
  • It does work when I load the entire record set when creating the QueryableCollectionView
    (of course, I do NOT want to do this, that's why I use paging)
  • I also tried by binding the DataPager Source to the QueryableCollectionView, but this has the same behavior.
    <telerik:RadGridView
             ItemsSource="{Binding MyQueryableCollectionView}"
             AutoGenerateColumns="True" />         
    <telerik:RadDataPager
             Source="{Binding MyQueryableCollectionView}"
             PageSize="10" DisplayMode="All" />

2 Answers, 1 is accepted

Sort by
0
Koen
Top achievements
Rank 1
answered on 20 Sep 2013, 06:40 AM
For future reference, I've found a solution to this problem:

The IQueryable that you set as the source of the QueryableCollectionView MUST be ordered. 
Otherwise, you'll get the behavior described in this post.

I guess this makes sense in some way;
If you're not ordering the IQueryable, Entity Framework is unable to execute skip methods on it;
Underlying, this exceptions occurs: 

The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.



Regards,
Koen
0
Dimitrina
Telerik team
answered on 20 Sep 2013, 01:52 PM
Hi,

Thank you for sharing your solution with the community. 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Koen
Top achievements
Rank 1
Answers by
Koen
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or