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

[Solved] How to obtain the Column and sort direction clicked?

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vincent
Top achievements
Rank 1
vincent asked on 04 Feb 2010, 09:17 PM
I would like to obtain the Column name and the direction of the sort when the user clicks a header name.  I'll be storing this in a cookie so that the next time the page is visited, I can automatically sort the grid to display what they last viewed.  How do I do this?

Thanks

Vincent

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Feb 2010, 06:07 AM
Hello Vincent,

You can get the ColumnName and SortDirection in the PreRender event as shown below.

CS:
 
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        if (RadGrid1.MasterTableView.SortExpressions.Count != 0) 
        { 
            string name = RadGrid1.MasterTableView.SortExpressions[0].FieldName; 
            GridSortOrder order = RadGrid1.MasterTableView.SortExpressions[0].SortOrder; 
        }  
    } 

-Shinu.
0
vincent
Top achievements
Rank 1
answered on 05 Feb 2010, 03:58 PM
Shinu,

That worked like a charm.  Thanks for the quick reply!

Vincent
Tags
Grid
Asked by
vincent
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
vincent
Top achievements
Rank 1
Share this question
or