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

When using ContextMenuControlTarget class the context menu appears in header as well

1 Answer 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Goran
Top achievements
Rank 1
Goran asked on 11 Jan 2013, 08:11 AM
Hi,

The Telerik's grid is incorporated in our user control (derived from UserControl). I had a requirement to allow context menu to show up on grid's row and we use RadContextMenu in conjunction with ContextMenuControlTarget. Actually, I have to use ContextMenuControlTarget. I have a simple test project where everything works fine with RadContextMenu only. But, in our main complex project I have to use ContextMenuControlTarget to show grid's context menu. If I don't use it the context menu doesn't appear. I don't know why.

So, I'm not sure when to use RadContextMenu only and when with ContextMenuControlTarget.

There's another issue. When I use ContextMenuControlTarget the context menu appears not only when I select grid's row but in header as well. We don't need the context menu to appear in header.

Here's the code I use:

public class GridContextMenu : RadContextMenu
{
    ...
}

protected override void OnInit(EventArgs e)
{
  base.OnInit(e);

  var contextMenu =
new Parus.Controls.GridContextMenu();

  var target =
new ContextMenuControlTarget();
  target.ControlID = this.GridControl.ID;

  contextMenu.ID =
this.GridControl.ID + "_RadMenu";

  CreateContextItems(contextMenu.Items,
this.Frame.ViewFrameData.ActionItems);

  contextMenu.LinkedControlClientId = ServerRequest.ClientID;
  contextMenu.OnClientItemClicked = "GridContextMenu_ActionsHandler";

  contextMenu.Targets.Add(target);

  this
.PostbackPanel.ContentTemplateContainer.Controls.Add(contextMenu);

  ...
}

My question is - how can I get rid of ContextMenuControlTarget or if it's not possible how to disallow it to appear in grid's header?

1 Answer, 1 is accepted

Sort by
0
Goran
Top achievements
Rank 1
answered on 14 Jan 2013, 05:04 AM
Could someone, please, answer this question?

Thanks.
Tags
Grid
Asked by
Goran
Top achievements
Rank 1
Answers by
Goran
Top achievements
Rank 1
Share this question
or