Hello Telerik Team,
I have the following scenario:
a raddatagrid, using a radajaxmanager, created programmatically, populated in "onneeddata"
a radmenu acting as a context menu, also created programmatically, and populated with (hierarchical) menu items
client-side listener on onrowcontextmenu on the grid, which looks like this:
I face two problems
1) When I first right click on a row, only the top level menu items are set with "setMenuLink", because "menuitem._children is null. When I wait for a second and right click a second time, menuitem._children has the correct entries and everything works. How can I change my approach to make this work?
2) If a ajax postback happens (by filtering, grouping, sorting, changing the page etc.) the contextmenu stops working. onrowcontextmenu is triggered, and
var menu = $find("ctl00_ccp_rgid");
even returns the correct menu object, but no menu is drawn on screen, neither is the onclientshowing event triggered. The ContextMenu is created programmatically like this (snippet from the OnInit-Method of the UserControl (a derivate from a radsplitter) hosting both the grid and the context menu):
Any help is greatly appreciated
best regards
Ulrik
I have the following scenario:
a raddatagrid, using a radajaxmanager, created programmatically, populated in "onneeddata"
a radmenu acting as a context menu, also created programmatically, and populated with (hierarchical) menu items
client-side listener on onrowcontextmenu on the grid, which looks like this:
function RowContextMenu(sender, eventArgs) { |
var menu = $find("ctl00_ccp_rgid"); |
var id = eventArgs.getDataKeyValue("ID"); |
for (var i = 0; i < menu._children._array.length; i++) { |
setMenuLink(menu._children._array[i],id); |
} |
} |
function setMenuLink(menuitem, id) { |
if (menuitem._linkElement != null) { |
setID(menuitem._linkElement.href, id); |
menuitem._linkElement.href = setID(menuitem._linkElement.href, id); } |
if (menuitem._children != null && menuitem._children._array != null) { |
for (var i = 0; i < menuitem._children._array.length; i++) { |
setMenuLink(menuitem._children._array[i], id); |
} |
} |
} |
I face two problems
1) When I first right click on a row, only the top level menu items are set with "setMenuLink", because "menuitem._children is null. When I wait for a second and right click a second time, menuitem._children has the correct entries and everything works. How can I change my approach to make this work?
2) If a ajax postback happens (by filtering, grouping, sorting, changing the page etc.) the contextmenu stops working. onrowcontextmenu is triggered, and
var menu = $find("ctl00_ccp_rgid");
even returns the correct menu object, but no menu is drawn on screen, neither is the onclientshowing event triggered. The ContextMenu is created programmatically like this (snippet from the OnInit-Method of the UserControl (a derivate from a radsplitter) hosting both the grid and the context menu):
if (this.GridController.DataGrid is WebControl) |
{ |
ContextMenuControlTarget target = new ContextMenuControlTarget(); |
target.ControlID = (this.GridController.DataGrid as WebControl).ID; |
(this.GridController.DataGrid as RadGrid).ClientSettings.ClientEvents.OnRowContextMenu = "RowContextMenu"; |
RadContextMenu menu = new RadContextMenu(); |
menu.OnClientShowing = "OnClientShowing"; |
menu.ID = "rgid"; |
ICollection<WebNavigationNode> nodes = (this.Engine as ASPNetTelerikEngine).GetNavigationNodesForRecord(this.Record); |
foreach (WebNavigationNode node in nodes) |
{ |
this.addNavigationNode(menu, null, node); |
} |
menu.Targets.Add(target); |
menu.Skin = this.Skin; |
gridpane.Controls.Add(menu); |
} |
Any help is greatly appreciated
best regards
Ulrik