RadGridView, Paging, QueryableCollectionView & EntityFramework

3 posts, 0 answers
  1. Koen
    Koen avatar
    27 posts
    Member since:
    Apr 2012

    Posted 18 Sep 2013 Link to this post

    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. Koen
    Koen avatar
    27 posts
    Member since:
    Apr 2012

    Posted 20 Sep 2013 Link to this post

    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
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Sep 2013 Link to this post

    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 >>
Back to Top