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

Create RadTreeViewContextMenu from client using XML

5 Answers 194 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
relper
Top achievements
Rank 1
relper asked on 29 Feb 2008, 02:16 AM
Hi,

Is it possible to create the RadTreeViewContextMenu from client javascript code? If so, can use an equivalent to server LoadXml() method to load it's contents?

Thanks!

5 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 29 Feb 2008, 07:56 AM
Hi relper,

RadTreeViewContextMenu is a separate control used by RadTreeView. RadTreeView does not support client-side creation of context menus.

For client-side modification of the RadTreeViewContextMenu you can create an empty one and add it to the RadTreeView on the server. You can then populate its nodes dynamically on the client as needed.

I hope this helps.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
relper
Top achievements
Rank 1
answered on 29 Feb 2008, 03:48 PM
Thanks Erjan.

But I’m having problems to find the right functions on the client. What I did was to define the empty context menus (5 total) on the tree, in the aspx page. Then on the client I’m trying to get the context menu object and add the items using LoadXml. The actual xml comes from a web service call. Coul you please provide some sample code that does something like that? Thanks!

0
Erjan Gavalji
Telerik team
answered on 03 Mar 2008, 01:52 PM
Hi relper,

RadTreeView doesn't have webservice context menu item population out of the box. This could be a nice feature though, so we will give it a try in the future. Currently this can be implemented by the aid of some javascript code.

Please, find attached an example I just created. The demo creates a webservice loader in the RadTreeView's ContextMenuShowing client event and loads the root items. The children are loaded in the standard RadMenu way - by using the WebServiceSettings property of the RadTreeViewContextMenu.

I hope this helps.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Accepted
Erjan Gavalji
Telerik team
answered on 03 Mar 2008, 01:59 PM
Hi again relper,

I forgot mentioning, that the workaround uses a private client-side method of the RadContextMenu - _loadFromDictionary(itemData), which assigns menu property values from the itemData parameter.

Cheers,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
relper
Top achievements
Rank 1
answered on 04 Mar 2008, 03:49 PM
Thanks Erjan! This will do. I'll still have to "translate" the XML format I have my menus to the RadMenuItemData on the web service but I don't hink it will be a problem. Thanks again.
Tags
TreeView
Asked by
relper
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
relper
Top achievements
Rank 1
Share this question
or