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

Emulate column header click

1 Answer 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 09 May 2013, 09:39 PM
We have columns that sort the default way, which is fine. No custom sorting.

What we want to do, however, is skip the SortingState.None... and always either sort ascending or descending.

So what I tried was to capture the Column.SortingStateChanged event, and set the state to "Ascending" when the new state was "None". This did not have the desired effect.

I expected the column to sort the grid by its values in Ascending order. Instead, it assigned the current state (unsorted) to Ascending.

----

In summary, we don't want three-state sorting. We want ascending or descending only, once a user clicks on the column header.



Thanks,
Chad Lehman
20th Century Fox

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 10 May 2013, 06:27 AM
Hi,

You have to handle the Sorting event of RadGridView.

You may try something like :
public MainPage()
       {
           InitializeComponent();
           this.RadGridView1.Sorting +=RadGridView1_Sorting;
       }
 
 
private void RadGridView1_Sorting(object sender, GridViewSortingEventArgs e)
       {
           if (e.NewSortingState == SortingState.None)
               e.NewSortingState = SortingState.Ascending;
       }


Let me know in case this does not do the trick.

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Chad
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or