In this topic, you will learn how to Add/Remove WebGrid's context menu.
To remove "Copy this row" from context menu
Add OnRowContextMenu client-side event:
JavaScript | Copy Code |
function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) { menuObject.Items.GetNamedItem("mnuCopyRow").Hide(); return true; } |
To add a menu to context menu
Add OnRowContextMenu client-side event:
JavaScript | Copy Code |
function WebGrid1_OnRowContextMenu(controlId, rowType, rowElement, menuObject) { var separator = new WebMenuItem(); separator.Type = "Separator"; separator.Name = "MySeparator"; var menuItem = new WebMenuItem(); menuItem.Text = "View Row's KeyValue"; menuItem.Name = "MyMenu"; menuItem.OnClick = "RowKeyValue"; // Add Menu Separator and Menu Item menuObject.Items.Add(separator); menuObject.Items.Add(menuItem); } function RowKeyValue() { var grid = ISGetObject("WebGrid1"); var key = grid.GetSelectedObject().GetRowObject().KeyValue; alert(key); } |