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

commanditem context menu

3 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerome
Top achievements
Rank 1
Jerome asked on 30 Sep 2010, 04:37 PM
I would like to display the grids header context menu from the commanditem above the grid.  Is this possible?

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 01 Oct 2010, 02:40 PM
Hi Jerome,

My suggestion is that you try to implement a custom context menu if you want it to be shown from the CommandItem, as the HeaderContextMenu is meaningful to use only when it is applied on RadGrid columns, if it is triggered by a click on the CommandItem, it does not know which column should the certain action be performed on. What functionality would you want the menu to expose and on what parts of RadGrid?

Kind regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerome
Top achievements
Rank 1
answered on 01 Oct 2010, 04:40 PM
Hi Tsvetina,
  I'm trying to duplicate the functionality of hiding and showing the columns available for the grid. 
I tried to create a custom menu but wasn't able to get the checkboxes to display for items other than on level 0. I have a question posted to see about resolving that as well.  http://www.telerik.com/community/forums/aspnet-ajax/menu/dynamic-menuitems-as-checkboxes.aspx 

  I was hoping I could use the context menu from the grid and only expose the columns options.
0
Tsvetina
Telerik team
answered on 06 Oct 2010, 12:52 PM
Hi Jerome,

An alternative approach would be to remove the other options from the HeaderContextMenu and leave only the Columns menu. You can achieve that by wiring the server-side PreRender event of the HeaderContextMenu and there hide all unnecessary items:
protected void Page_Init(object sender, EventArgs e)
{
    RadGrid1.HeaderContextMenu.PreRender += new EventHandler(HeaderContextMenu_PreRender);
}
private void HeaderContextMenu_PreRender(object sender, EventArgs e)
{
    GridHeaderContextMenu menu = sender as GridHeaderContextMenu;
    foreach (RadMenuItem item in menu.Items)
        if (item.Text != "Columns")
        {
            item.Visible = false;
        }
}

I hope that this approach results in the desired functionality.

Greetings,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jerome
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Jerome
Top achievements
Rank 1
Share this question
or