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

[Solved] Custom Sorting - using Viewstate data only?

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 24 Mar 2008, 11:36 PM
I am using a grid with custom sorting and using the OnNeedDataSource tag which I use to fetch some data from a remote source (a lengthy call).

I want to enable custom sorting ... is there a way to do this so that I can sort the data in the grid entirely using the grid's Viewstate? I want to avoid making the query again (expensive because it is database plus network service calls)?

Is the Grid's data contained entirely in the Viewstate? Or do I have to re-create my Datasource every time the user sorts a column?

Thanks!!

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 25 Mar 2008, 07:30 AM
Hi Jay,

The grid saves in ViewState only items/controls collection not data source data. To avoid unnecessary requests to your data base server you can cache your data.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jay
Top achievements
Rank 1
answered on 25 Mar 2008, 05:37 PM
Hi,

I am a little confused. The doc "Optimizing ViewState usage" says "Typically RadGrid stores its dataset in the page view state, so that it can be reinitialized without hitting the data layer on postback events. This can be both a good and a bad thing. It is good because it reduces the load on the database server."

Is there any way to avoid the NeedDataSource from being called when a column is selected for sorting? What information is stored in the ViewState? You say that items/controls are stored ... is this the actual values for the grid entries?

Thanks!
0
Sebastian
Telerik team
answered on 28 Mar 2008, 02:38 PM
Hello Jay,

This seems to be incorrect information and we will remove it from the relevant help article for the next version of the product help. Please excuse us if this confused you.

As my colleague Vlad said:
The grid saves in ViewState only items/controls collection, not data source data

There are commands that invoke the Rebind() method of the grid implicitly (and raise NeedDataSource event respectively) and they are listed here. Further details about the event lifecycle of the control can be found in the following article from the online documentation:

RadGrid event sequence

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jay
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or