Welcome Guest Search | Active Topics | Sign In | Register

Treeview Traversal Options
Kris
Posted: Tuesday, July 22, 2008 1:49:39 AM
Rank: Newbie
Groups: Member

Joined: 7/13/2008
Posts: 3
Hi
I have created a treeview with context menu items Add, Edit and Delete and which is put inside a Callback panel using XML Data source.
From the server side code ,

1.Is there any direct method to get the modified XML from the tree view after some add/edit/delete events?

2.Is there any functions available for traversing through the tree?

Please give me your valuable suggestions on the above issue

unni
eo_support
Posted: Tuesday, July 22, 2008 3:55:23 AM
Rank: Administration
Groups: Administration

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

The TreeView doesn't have either of that built in. But it's quite easy to write one. The following code creates XML from a TreeNodeCollection object:

private string BuildTreeNodeXml(
EO.Web.TreeNodeCollection nodes, string indent)
{
string xml = indent + "<nodes>\r\n";

string childIndent = indent + " ";

foreach (EO.Web.TreeNode node in nodes)
{
xml += childIndent + string.Format("<node text=\"{0}\">\r\n", node.Text);

if (node.ChildNodes.Count > 0)
xml += BuildTreeNodeXml(node.ChildNodes, childIndent);

xml += childIndent + "</node>\r\n";
}

xml += indent + "</nodes>\r\n";

return xml;
}

You can then call:

BuildTreeNodeXml(TreeView1.Nodes, "");

To get the XML based on the whole TreeView. Note you will need to modify the sample code to use your own specific tag and attribute name. The sample code uses "nodes" for node collection, "node" for TreeNode and "text" for tree node text.

Hope this helps.

Thanks
Kris
Posted: Tuesday, July 22, 2008 5:12:06 AM
Rank: Newbie
Groups: Member

Joined: 7/13/2008
Posts: 3

Hi

Thank you for your help.




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.