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

[EFDS + RadGridView] Sort items on current page.

5 Answers 67 Views
EntityFrameworkDataSource
This is a migrated thread and some comments may be shown as answers.
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 23 Sep 2015, 09:25 AM

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?

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 28 Sep 2015, 08:45 AM
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
0
Jakub
Top achievements
Rank 1
Iron
answered on 28 Sep 2015, 10:13 AM

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

0
Stefan
Telerik team
answered on 01 Oct 2015, 09:18 AM
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
0
Jakub
Top achievements
Rank 1
Iron
answered on 07 Oct 2015, 10:50 AM

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.

0
Ivan Ivanov
Telerik team
answered on 12 Oct 2015, 10:58 AM
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
Tags
EntityFrameworkDataSource
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Jakub
Top achievements
Rank 1
Iron
Ivan Ivanov
Telerik team
Share this question
or