Welcome Guest Search | Active Topics | Sign In | Register

TreeView - Question about adding new nodes Options
Webideal
Posted: Thursday, August 9, 2007 8:25:25 AM
Rank: Member
Groups: Member

Joined: 6/14/2007
Posts: 9
Hello, I'm new to EO.WEB control , moreover, I'm new to ASP.NET. I have been exploring the treeView propertie since yesterday and I'm wondering if I can add new nodes, but not from the treebuilder. I'd like to be able to create nodes by (for example) right clicking on the root node.
Maybe there's a property for that, like create new folder, something like that.

In those new folders I'd like to create, a list of contacts would be displayed at the right of the TreeView. This control is a devExpress one we already bought.

Please help me for that :)

Thxo Angel
eo_support
Posted: Thursday, August 9, 2007 8:43:06 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

You question actually contains multiple questions, I will try to answer them one by one.

1. You can add new node on the server side, but not on the client. The easiest scenario is that you have a TreeView and a Button, when user clicks the button, you would add a node to the TreeView. In order to accomplish this you simply do this in your Button1_Click handler:

TreeView1.Nodes.Add("new node");

There are other overloads for the Add method, you can take a look of the documentation.

2. Now you probably don't want to use a button, but a right click context menu. For that you will want to use a ContextMenu control and display it by set the TreeView's ClientSideOnContextMenu property. You can take a look of this sample:

http://www.essentialobjects.com/Demo/Default.aspx?path=TreeView\_i1\_i9

You have all the source code of the sample on your local drive. So you will want to take a look of that and see how it is implemented.

Now you would need to set the ContextMenu's RaisesServerEvent to true, so that when you click a context menu item, it triggers the context menu's ItemClick event on the server side. Now you can move the code that was in Button1_Click to ContextMenu1_ItemClick.

Now you can right click a tree node, the context menu will display. Clicking a context menu item will post back the page and executes ContextMenu1_ItemClick, which creates a new node. When the page refreshes, you will see the new node.

3. From there on you may want to avoid full page reload. In order to do that you would use our CallbackPanel control. Place a CallbackPanel in the form, move the TreeView inside the CallbackPanel. Then edit the CallbackPanel's Trigger control to add the ContextMenu as a trigger. Now when you click the context menu item, the TreeView will be refreshed to reflect the newly created node, but other part of the page won't reload.

I am not sure what you mean by "a list of contacts would be displayed at the right of the TreeView". That doesn't appear to have anything to do with the TreeView. I don't know what you mean by "this control is a devExpress one we already bought". We have no association with devExpression.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.