I have a RadTreeViewContextMenu on a RadTree that contains an Item Template with a textbox. button, and customvalidator. On Postback, I need to display the RadTreeViewContextMenu if validation fails. I'm at a loss on how to do this. Any ideas?
Thanks in advance,
Gene.
Thanks in advance,
Gene.
3 Answers, 1 is accepted
0
Hi Gene,
Here is how you can do this: if the validation fails register a javascript by using RegisterStartupScript method of the ScriptManager class. That javascript will do the following: finds the context menu and shows it using the showAt client-side method of the menu.
Here is a sample C# code:
I hope this will get you started.
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Here is how you can do this: if the validation fails register a javascript by using RegisterStartupScript method of the ScriptManager class. That javascript will do the following: finds the context menu and shows it using the showAt client-side method of the menu.
Here is a sample C# code:
StringBuilder script = new StringBuilder(); |
script.Append("Sys.Application.add_load(function(){"); |
script.Append("var menu = $find('" + RadTreeView1.ContextMenus[0].ClientID + "');"); |
script.Append("menu.showAt(100, 100);"); |
script.Append("});"); |
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "openContext", script.ToString(), true); |
I hope this will get you started.
Greetings,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gene
Top achievements
Rank 1
answered on 18 Aug 2009, 04:22 PM
Thanks for your reply Veselin!
Works great! Next question: How do I dynamically get the position of the contextmenu?
Thanks again,
Gene.
Works great! Next question: How do I dynamically get the position of the contextmenu?
Thanks again,
Gene.
0
Accepted
Hi Gene,
Supposing you want to show the context menu over the selected node here is the amended code:
Sincerely yours,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Supposing you want to show the context menu over the selected node here is the amended code:
StringBuilder script = new StringBuilder(); |
script.Append("Sys.Application.add_load(function(){"); |
script.Append("var menu = $find('" + RadTreeView1.ContextMenus[0].ClientID + "');"); |
script.Append("var tree = $find('" + RadTreeView1.ClientID + "');"); |
script.Append("var node = tree.get_selectedNode(); if (node) {"); |
script.Append("var nodeLocation = $telerik.getLocation(node.get_textElement());"); |
script.Append("menu.showAt(nodeLocation.x + 20, nodeLocation.y + 10);}"); |
script.Append("});"); |
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "openContext", script.ToString(), true); |
Sincerely yours,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.