The control has some features that the .NET
Treeview does not have:
- Drag and drop nodes (just set
- Editable nodes (just set the
Editable property to
- Server-side events for node moved and node edited
See the tree live here and here.
To join the project, click here.
To see samples for all the controls in the DLL, click here.
Using the Code
Just add the DLL for the controls to your toolbox, drag and drop to your ASPX page and set some properties:
<cc1:TreePane ID="TreePane" Editable="true" enableDD="true"
Loader="TreeHandler.ashx" Width="400px" runat="server"
You can add nodes to the tree in the designer or through code:
GridControl.TreeNode root = new GridControl.TreeNode();
root.id = "0";
root.leaf = false;
root.text = "root";
To load nodes dynamically, you can use the
Loader property of the control. The code for the loader page looks something like this:
for (int i = 0; i < ds.Tables.Rows.Count; i++)
TreeNode no = new TreeNode();
no.draggable = true;
no.id = ds.Tables.Rows[i]["id"].ToString();
no.text = ds.Tables.Rows[i]["text"].ToString();
no.leaf = !HasChildren(ds.Tables.Rows[i]["id"].ToString());
no.parentNodeId = context.Request["node"];
Points of Interest
The control was created with the events all fired through callback, then I was surprised while trying to integrate it with the Update Panel. The events where not being fired!
So after some researching and thinking, I implemented postback for the events and added a new property (
AutoPostBack) to the control and voila! The events were working and the Update Panel was making them happen without a refresh.
This is a year old CodePlex project that has other cool controls.