Merging context menu for radGrdidView with RadContextMenu

4 posts, 1 answers
  1. Czeshirecat
    Czeshirecat avatar
    30 posts
    Member since:
    Jun 2016

    Posted 23 Jun Link to this post

    Hi.

    RadGridView has it's own context menu that displays when right clicking the various sections of the control.

    I want to merge my own context menu with it but I can't see how to do this. If I set the context menu with the context menu manager i get 2 overlapping context menus when I right click.

    (radcontextmenu has no allowmerge property)

    thanks.

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1869 posts

    Posted 26 Jun Link to this post

    Hi Claire,

    You need to add your items to the default context menu. This can be done by using the ContextMenuOpening event. An example is available here: Modifying the Default Context Menu.

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Czeshirecat
    Czeshirecat avatar
    30 posts
    Member since:
    Jun 2016

    Posted 26 Jun Link to this post

    thanks for this.

    I guessed how to do it before your reply and I originally used the following code to copy the items in my design time context menu across to the default.

    It worked fine when I right clicked the main area of the data grid, but if I right clicked the navigation bar, then right clicked the data grid I received an exception "Cannot remove the specified item because it was not found in the specified Collection.".

    There's no error if I create the menu items every time so I believe they are disposed of behind the scenes.

    private void dataGrid_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
    {
      for (var idx = 0; idx < radContextMenu1.Items.Count; idx++)
        e.ContextMenu.Items.Add(radContextMenu1.Items[idx]);
    }// function
  4. Dimitar
    Admin
    Dimitar avatar
    1869 posts

    Posted 26 Jun Link to this post

    Hello Claire,

    Which part you of the grid you are considering to be "navigation bar"? I have tested this with a regular grid and it works fine on my side. Are you using the context menu for other control?

    I am looking forward to your reply.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top