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

Header Context Menu Click

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 07 Aug 2012, 01:10 PM
Hello,

I really have to say that I enjoy your Header Context Menu for the Rad Grid. I am currently trying to customize it for my project, using HeaderContextMenu_ItemCreated to set "Group by" and "Ungroup" invisible, and OnPreRenderComplete to add my own Rad Menu Items to it.
However, I would like to know how to access the click event of the Rad Menu Items I have added myself. Do I have to add an event handler here?

Thanks in advance,
Robin

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 10 Aug 2012, 12:47 PM
Hello Robin,

You could achive this using the following code snippet:
protected void Page_Load(object sender, EventArgs e)
{
    RadGrid1.HeaderContextMenu.ItemClick += new RadMenuEventHandler(HeaderContextMenu_ItemClick);
}
 
protected void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
{
 
}

For more information about customizing Header Context Menu please refer to this help article.

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Robin
Top achievements
Rank 1
answered on 14 Aug 2012, 07:31 AM
Hi Kostadin,

I tried the following code based on your suggestion and the related help article:
protected void Page_Load(object sender, EventArgs e)
    {
        RadGrid1.HeaderContextMenu.ItemClick += new RadMenuEventHandler(HeaderContextMenu_ItemClick);
    }
 
protected void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
    {
        switch (e.Item.Text)
        {
            case "Option1": [...]; break;
        }
    }

However, that doesn't seem to work the way I way hoping it would. When I start the project and select the "Option1" at my Header Context Menu, I get an error (System.NullReferenceException), telling me that the Object reference has not been set to an object instance.

Any further suggestions would be of great help.

Thanks in advance,
Robin
0
Kostadin
Telerik team
answered on 15 Aug 2012, 01:47 PM
Hello Robin,

In order to examine your case and tell you the reason for this exception we will need your code declaration. So please post it here and indicate the exact line where the exception is thrown.

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Robin
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Robin
Top achievements
Rank 1
Share this question
or