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
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
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
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
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.
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;
}
}
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