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

context menu on gridbutton click

1 Answer 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Allen
Top achievements
Rank 1
Allen asked on 29 Nov 2013, 08:09 AM
Hi,

How can I show context menu on gridbutton click? somebody please help.

Thanks
Allen

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Nov 2013, 08:22 AM
Hello,

Try the following code to show context menu on click of button.

ASPX:
<telerik:GridButtonColumn UniqueName="Select" Text="click" ButtonType="LinkButton"></telerik:GridButtonColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
   GridDataItem item = (GridDataItem)e.Item;
   LinkButton btn = (LinkButton)item["Select"].Controls[0];
   btn.OnClientClick = "showMenu(this, event); return false;";
  }
}

Javascript:
function showMenu(sender, args) {
        var contextMenu = $find("<%= RadContextMenu1.ClientID %>");
        contextMenu.show(args);
}

Thanks,
Princy.
Tags
Grid
Asked by
Allen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or