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

EnableHeaderContextMenu

4 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sathies
Top achievements
Rank 1
sathies asked on 22 Dec 2008, 01:40 PM
Hi,

Is  it possible to customize the EnableHeaderContextMenu? i.e.) There are four columns in a grid , suppose user hides the two columns.Next time when he see the grid it should only contains two columns which was selected previously but not  all.


4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 22 Dec 2008, 01:56 PM
Hello Sathies,

You can access the items in the context menu on ItemCreated/ItemDataBound events:
void HeaderContextMenu_ItemCreated(object sender, RadMenuEventArgs e) 
    //your code
protected void RadGrid1_Load(object sender, EventArgs e) 
    RadGrid1.HeaderContextMenu.ItemCreated += new RadMenuEventHandler(HeaderContextMenu_ItemCreated); 

Let us know if you need further assistance.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
sathies
Top achievements
Rank 1
answered on 29 Dec 2008, 02:17 PM
Hello Daniel,

   Thanks for your Reply.

I tried your code its working but i couldn't get access to the column names in the grid. Please help me in this regard.
Also give  example for the above.

regard,
sathies
0
Shinu
Top achievements
Rank 2
answered on 30 Dec 2008, 09:27 AM
Hi Sathies,

You can try the following code snippet to access the Column names in the code behind.

CS:
 foreach (RadMenuItem item in RadGrid1.HeaderContextMenu.Items[7].Items) 
        { 
            int count=RadGrid1.HeaderContextMenu.Items[7].Items.Count; 
            for (int i = 0; i <= count-1; i++) 
            { 
                string strName = RadGrid1.HeaderContextMenu.Items[7].Items[i].Value; 
                string strColName = strName.Split('|')[1]; 
            } 
            break
        } 



Shinu
0
Daniel
Telerik team
answered on 30 Dec 2008, 01:52 PM
Hello Sathies,

Please test the example attached to this post.

Let us know whether this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
sathies
Top achievements
Rank 1
Answers by
Daniel
Telerik team
sathies
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or