Home - Forums-.NET - FlyTreeView (ASP.NET) - Dynamically setContext Menu items

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Dynamically setContext Menu items
Link Posted: 11-Nov-2007 22:47
Can you give example of how to set Items to the context menu dynamically, according to the Node Type selected, using external source (like XML). (Not to use several instances of the context menu)
Thanks
Link Posted: 12-Nov-2007 01:32
For context menu, you can set Text/CommandName/etc for menu items at client side. But you cannot add/remove menu items.

You can get example at:
http://www.9rays.net/asp.net_2/treeview/Demo_Office2003.aspx

See the HandleContextMenuPopup javascript funtion.

Also the following client-side API descriptions (CFlyContextMenu and CFlyMenuItem sections):
http://www.9rays.net/asp.net_2/treeview/miscpages/doc/ClientObjects.aspx
Link Posted: 02-Dec-2007 01:18
What do you mean i cannot add/remove items at runtime?

Can you please advise how can i add DYNAMIC context?
Lets take example of a bookstore tree constructed from XML:
http://samples.gotdotnet.com/quickstart/util/srcctrlwin.aspx?path=/quickstart/howto/samples/Xml/StreamXmlDocument/cs/&file=books.xml
I have many node types like- Bookstore, book, author, price  etc.

for each one of the node types i need to add or remove context menu items at runtime.
Examples for different functionalities:
1) bookstore: Close bookstore
2) book: Change Cover
3) Price: Make discount
etc.

its a different context for each node.

1. I want to make the changes at runtime!
2. I need to add and remove items at runtime according to the selected tree node.
3. ant the user to right click on an unselected node and it will be selected, expanded and a popup context menu with the relevant items (i can make the selection and expamding but withour context menu)
4. I have to load the relevant context from an outer source like xml or text or resource file.

Thanks
Link Posted: 02-Dec-2007 07:00
[quote="hagay"]What do you mean i cannot add/remove items at runtime?

Yes, you cannot add/remove context menu items at client-side. You can only change menu items properties.

[quote="hagay"]
Can you please advise how can i add DYNAMIC context?
Lets take example of a bookstore tree constructed from XML:
http://samples.gotdotnet.com/quickstart/util/srcctrlwin.aspx?path=/quickstart/howto/samples/Xml/StreamXmlDocument/cs/&file=books.xml
I have many node types like- Bookstore, book, author, price  etc.

for each one of the node types i need to add or remove context menu items at runtime.
Examples for different functionalities:
1) bookstore: Close bookstore
2) book: Change Cover
3) Price: Make discount
etc.

its a different context for each node.

The only way is to have multiple context menu instances on your page (for every node type).


[quote="hagay"]
1. I want to make the changes at runtime!

This is not possible with FlyContextMenu.

[quote="hagay"]
2. I need to add and remove items at runtime according to the selected tree node.

All what client-side CFlyContextMenu can do is to modify existing menu items properties    
( http://www.9rays.net/asp.net_2/treeview/miscpages/doc/ClientObjects.aspx )

[quote="hagay"]
3. ant the user to right click on an unselected node and it will be selected, expanded and a popup context menu with the relevant items (i can make the selection and expamding but withour context menu)

Current implementation does not select nodes with right-click. Anyway this behavior can be changed.


[quote="hagay"]
4. I have to load the relevant context from an outer source like xml or text or resource file.

With javascript? There's no way to build new context menu at client side.
Link Posted: 02-Dec-2007 20:58
OK. thanks for your answers.

Hagay