[EFDS + RadGridView] Sort items on current page.

6 posts, 0 answers
  1. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 23 Sep 2015 Link to this post

    Hi,

     

    I have RadGridView binded to QueryableEntityCollectionView. I want to sort only items on current page by click on column header, not  full data from server.

    I was trying to sort items in GridView_Sorting event, set e.NewSortingState  and e.Cancel = true but without any success. Can't access and sort items from current page.

     

    Any help?

  2. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 28 Sep 2015 Link to this post

    Hello Jakub,

    Generally, in such scenarios you can bind the ItemsSource of RadGridView to the PagedSource property of RadDataPager. You can take a look at the following example.
    <telerik:RadGridView Grid.Row="0"
                         Name="clubsGrid"
                         ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
                         Margin="5">
    </telerik:RadGridView>
    <telerik:RadDataPager x:Name="radDataPager"
                          PageSize="20"
                      Source="{Binding Clubs}"
                          VerticalAlignment="Bottom"/>

    Note, that the Source property of RadDataPager is bound to the collection holding all items.

    Can you please give it a try and let me know how it goes?

    Best Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 28 Sep 2015 Link to this post

    Hello, and thank you for your answer Stefan.

    Unfortunately, when ItemsSource of RadGridView is binded to the PagedSource property of RadDataPager, RadGridView still sorting whole collection when one of the columns header is pressed, instead of items on page.

     

    I attached simple project when i was test some features and scenarious, you can see binding i am using as you mentioned, but i can't see expected effects. TabTest.zip

  5. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 01 Oct 2015 Link to this post

    Hello Jakub,

    I am investigating the case, however I will need more time for this. I will write you back as soon as I have a result.

    Thank you in advance for your patience.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Jakub
    Jakub avatar
    14 posts
    Member since:
    Sep 2015

    Posted 07 Oct 2015 Link to this post

    Hi Stefan,

     

    Did you manage to get a solution to this situation ? 

     

    I was thinking of two collections, where first is from EntityFrameworkDataSource and is binded to RadPager and second one is ObservableCollection or other binded to RadGridView. When first one will raise CollectionChanged, my ViewModel will reacts in such a way that copy elements from current page to collection binded to RadGridView. Then sorting, grouping and column filtering will be performed only on visible elements in RadGridView. I have not had time to try, but it seems a good walkaround solution.

  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 12 Oct 2015 Link to this post

    Hi Jakub,

    Please excuse us for the delayed reply. We reviewed your scenario and we can discuss some customziations to achieve the desired results. I will try to shed some more light on waht is happening under the hood. RadGridView relies on the ICollectionView and IEditableCollection view interfaces to process its data. Additionally it uses the IQueryable interface to execute  queries over its bound data source. RadDataPager relies on IPagedCollectionView to utilize paging. If the bound source collection does not implement these interfaces, both controls wrap it in a instance of QueryableCollectionView, which is one of the core collections of our data engine. Then the same instance is used by both controls to add data descriptors, or apply paging to it. However, as soon as such changes are made, all of the defined operations are then sequentially applied:
    protected virtual IQueryable CreateView()
           {
               if (this.TotalItemCount == 0)
               {
                   return this.ApplySelectDescriptors(this.QueryableSourceCollection);
               }
               else
               {
                   var queryable = this.QueryableSourceCollection;
                   queryable = queryable.Where(this.FilterDescriptors);
                   queryable = this.Sort(queryable);
                   queryable
                       = this.ApplySelectDescriptors(queryable);
                   queryable = queryable.GroupBy(this.GroupDescriptors);
                   queryable = queryable.Page(this.PageIndex, this.PageSize);
     
                   return queryable;
               }
           }
    We have a demo that treats a similar scenario of paging befire grouping: demos > RadGridView > Paging before grouping.
    Can you please have a look at it and tell us whether a similar customization would be applicable in your scenario. We can assist you wtih the concrete implementation if it is needed.

    Regards,
    Ivan Ivanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready