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

[Solved] Context Menu Sort with custom sort expressions

1 Answer 110 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen Kriss
Top achievements
Rank 1
Stephen Kriss asked on 17 Jun 2009, 10:58 PM
I am trying to use the grid Header Context Menu to make sorting easier for the user.  Some of my columns use custom sort expressions that are not strictly alphabetical.  The sorting that occurs due to using the context menu doesn't seem to respect these custom expressions.  How can I get the context menu to use my custom sort expressions?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 22 Jun 2009, 03:49 PM
Hello Stephen,

To achieve your goal you need to wire the ItemClick event of the HeaderContextMenu. This event will be raised when user clicks some item of the HeaderContextMenu. In ItemClick event handler you can reach RadMenuEventArgs, which contains clicked RadMenuItem. From it you can retrieve the value of the Item. You also will need the column which you will need to sort. To retrieve the column name please refer to the following code snippet:
    void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e) 
    { 
        string sortOrder = e.Item.Value; 
        string columnName = e.Item.Attributes["ColumnName"].ToString(); 
        string tableID = e.Item.Attributes["TableID"].ToString(); 
    } 

For further information how to sort depending on custom sort expression review this online help article.

Kind regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Stephen Kriss
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or