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

Sorting across pages?

3 Answers 83 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 07 Nov 2011, 04:56 PM
The RadDataPager works great for us, especially when it comes to speeding up the loading time for our records on the main page of our app (we were loading all of our records at the same time before, and there are a lot of them).

However, is it possible to sort data across pages when you're using the RadDataPager? Currently, when a user clicks on a column header in the RadGridView, it just sorts the records on that page. Would there be a way to sort all of the records across all pages when a user clicks a column header?

I'm assuming that we'll have to implement our own custom logic to get this to work, and I'm also assuming that we won't be able to get around the fact that we'll have to load all of the records in the gridview again, but I'm just wondering if anyone has found an efficient way to do this.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Nov 2011, 05:06 PM
Hi Nick,

Can you please share how have you connected RadGridView and RadDataPager?

If you data-bind RadDataPager.Source to RadGridView.Items you should get the behavior that you have described.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nick
Top achievements
Rank 1
answered on 21 Nov 2011, 11:13 PM
Thanks for the reply. 

Looking back on it now, I didn't truly connect the RadGridView and the RadDataPager in any way. Here is the xaml code for the RadDataPager:

<telerikPager:RadDataPager x:Name="rgvInventory_Pager" DisplayMode="All" PageSize="32"
                                   Margin="6,0,6,25" Width="749" Height="28" VerticalAlignment="Bottom" PageIndexChanged="rgvInventory_Pager_PageIndexChanged"/>

In the constructor of the window that uses it, I simply set its Itemcount:

rgvInventory_Pager.ItemCount = DataAccess.GetEquipmentCount();

When I load the actual equipment data, I just set the ItemsSource of the RadGridView ("rgvInventory"). I don't actually set the ItemsSource of the RadDataPager ("rgvInventory_Pager"):

rgvInventory.ItemsSource = result;
rgvInventory.IsBusy = false;

And this is how the data is actually loaded - it's only loaded by page:

 public static IEnumerable<Equipment> GetEquipmentByPage(int page, int pageSize)
 {
lock (database)
{
return database.Equipments
                    .OrderByDescending(i=>i.Id)
                    .Skip((page - 1) * pageSize).Take(pageSize);
}
}

The fact that we're only loading some of the records rather than all of them is what saves us time. It's unavoidable that we're going to have to load all of the equipment in order to sort all of it, right? I can set the RadDataPager's Source to be the RadGridView's Items collection, but that Items collection still needs to have everything if you want to sort all of the data. I know it's kind of a dumb question, but I'm just wondering if there are any tricks with the RadDataPager that might make dealing with this a little easier.

Thanks
0
Rossen Hristov
Telerik team
answered on 22 Nov 2011, 12:37 PM
Hello Nick,

So it seems that you are using RadDataPager in its Unbound Mode.

I am afraid that there is no magic way to sort all the data without actually having it.

Kind regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DataPager
Asked by
Nick
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Nick
Top achievements
Rank 1
Share this question
or