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

Can I access the sorted DataSource values on the server?

1 Answer 19 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 26 Jul 2010, 06:26 PM
I have a RadGrid being populated in code by a DataTable (unsorted). I'm trying to create a custom pager in the grid that displays a DropDownList with some optional additional info.

If the user is sorting the Grid by Date, I'd like the pager to display the items like:

[Page 1 - 1-Jan-2010 to 17-Jan-2010]
[Page 2 - 17-Jan-2010 to 4-Feb-2010]
(etc)

I'm able to populate the pager, but the dates I retrieve back are the unsorted dates in my DataTable - not the ones sorted in the grid. I'm doing this in my pager (a custom Pager class that inherits Control) in the CreateChildControls method. I do this by iterating through the pages in the Grid's DataSource (as DataTable), and on each page I get the date for the first and last displayed rows.

Is there a way I can accomplish this and still let the Grid handle the sorting? I know an alternative would be to provide a DataView to the Grid as the DataSource (and then handle the sorting expressions manually), but it seems like there should be a better (less code) way of accessing this already-sorted data.

Thanks,
Stefan

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 30 Jul 2010, 11:27 AM
Hello Stefan,

I am afraid that it is not possible to access the resolved data source that the grid is bound to when sort command is triggered. What you can do is get the unsorted data from your source (DataTable) and sort it manually using the sort expressions the grid creates when sort command is triggered. This way the sorted source you use to populate your custom pager control will match the source your grid is bound to and therefore there will be no need to manually sort the grid.

I hope this helps

Sincerely yours,
Martin
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Stefan
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or