Hello,
I create a RadGrid programmaticaly with a RadContextMenu, however, it always popup script error. The code is below:
1. Generate the RadContextMenu:
2. Bind to RadGrid:
3. Register the script:
How to add a RadContextMenu for dataitem? When users click a menu item, RadMenu1_ItemClick will be fired, how to get the column data as I need to set the navigationUrl for menu item?
TIA
BR
Jerry
I create a RadGrid programmaticaly with a RadContextMenu, however, it always popup script error. The code is below:
1. Generate the RadContextMenu:
| RadContextMenu RadMenu1 = new RadContextMenu(); |
| RadMenu1.ID = "RadMenu1"; |
| RadMenuItem viewItem = new RadMenuItem("View", "#"); |
| RadMenu1.Items.Add(viewItem); |
| RadMenuItem editItem = new RadMenuItem("Edit", "#"); |
| RadMenu1.Items.Add(editItem); |
| RadMenuItem deleteItem = new RadMenuItem("Delete", "#"); |
| RadMenu1.Items.Add(deleteItem); |
| this.Controls.Add(RadMenu1); |
| grid.ClientSettings.ClientEvents.OnRowContextMenu = "RowContextMenu"; |
| string script = @"<script type='text/javascript'> |
| function RowContextMenu(sender, eventArgs) |
| { |
| var menu = $find('<%=RadMenu1.ClientID %>'); |
| var evt = eventArgs.get_domEvent(); |
| menu.show(evt); |
| evt.cancelBubble = true; |
| evt.returnValue = false; |
| if (evt.stopPropagation) |
| { |
| evt.stopPropagation(); |
| evt.preventDefault(); |
| } |
| </script>"; |
| if (!this.Page.ClientScript.IsStartupScriptRegistered(typeof(String), "RowDblClick")) |
| { |
| this.Page.ClientScript.RegisterStartupScript(typeof(String), "RowDblClick", script); |
| } |
TIA
BR
Jerry
