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

How to change the sorting options to two and keep the sorting status automatically

3 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zhiyong
Top achievements
Rank 1
Zhiyong asked on 10 Aug 2010, 08:00 AM
Currently there are three sorting options, descending, ascending and no sorting. Could I limit to descending and ascending.

Also, everytime when a column is activated, the first sorting action is always ascending, is it possible to make it remember the last sorting status? If necessary, I can also write some code to keep track of the sorting state.

Thanks!
Joe

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 10 Aug 2010, 09:01 AM
Hi Zhiyong,

 
There is no problem to set the sorting order only to Ascending and Descending. What you need to do is just to handle the Sorting event of the grid and skip the none-sorting state. For example:

void playersGrid_Sorting(object sender, GridViewSortingEventArgs e)
{                      
    if (e.NewSortingState == SortingState.None)
    {
        e.NewSortingState = SortingState.Ascending;
    }
}

As for saving the last sorting state, you may use the method demonstrated in our online documentation and shown in our demos.

Greetings,
Maya
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
0
Zhiyong
Top achievements
Rank 1
answered on 12 Aug 2010, 08:57 AM
Thanks! The setting document seems a little bit overwhelming.

Do you mean I should simplely store the setting when they lost focus and restore sorting setting first at void playersGrid_Sorting(object sender, GridViewSortingEventArgs e), then do the reverse?

Best,
Zhiyong
0
Maya
Telerik team
answered on 12 Aug 2010, 09:42 AM
Hi Zhiyong,

Mainly, the idea explained in our online documentation is to show how to save the settings of the grid whenever it is unloaded/closed and to present that same grid with the same sorted/filtered/grouped state whenever it is loaded again. For saving those settings an Isolated Storage is used. In case you require to preserve only the Sorting settings, you may implement only the lines of the code corresponding to them. 
As you can see in our demos, if you sort the grid, go to another example and them come back to the Save & Load Settings example, you will prove that the grid is in the same sorted state as you have left it.
In case you have some specific requirements considering the Save & Load Settings functionality, we would need more details about your scenario in order to provide you with an appropriate solution.

Regards,
Maya
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
GridView
Asked by
Zhiyong
Top achievements
Rank 1
Answers by
Maya
Telerik team
Zhiyong
Top achievements
Rank 1
Share this question
or