Hi,
I'm using a WebTree with an XmlDataSource. In code I'm setting the Data property of the XmlDataSource to a valid XML string. This XML string has one rootnode. The WebTree is correctly bound to the XML string. But now I want to hide the root node of the XML string in the WebTree. Is that possible?
thanks,Jeroen
Not sure if anyone found this or not as its been a few years since this thread was active but since this is the first thread I found in searching for this question, I figured I would add it here...
This seems to work quite fine... as I have two controls on my page, a XmlDataSource and an UltraWebTree. In my code behind during the PreRender (or where ever you want to do it, such as Load or another event) I have the following:
MyXmlDataSource.XPath = "//SomeNodes/*[@enabled!='false']";
MyXmlDataSource.Data = "<SomeNodes><Node1 enabled=\"false\"><Node11><Node111 /></Node11></Node1><Node2 enabled=\"true\"><Node21><Node211 /></Node21><Node22><Node221 /></Node22></Node2></SomeNodes>"
;
MyUltraWebTree.DataSource = MyXmlDataSource;
MyUltraWebTree.DataBind();
This will set the root xml data presented from the XmlDataSource to be all the child nodes of the root Location node that dont have a attribute "enabled" equal to "false". So as long as the XPath selects the children of the root node, that's what your tree should show. You dont need the "[@enabled!='false']" parth of the XPath but I just thought it useful to show for easily filtering the tree content.
Baydon
Hello,
You can always suggest a new feature for any IG product using our Request Feature center located here:
http://devcenter.infragistics.com/Protected/RequestFeature.aspx
Our PMs regularly go through these and prepare a list of what to be implemented in the next release. Clone() functionality seems very reasonable (and in fact I can guarantee that it is already implemented in our next next generation treeview control - WebDataTree from the Aikido suite).
In any case, you can extend node and createyour own clonable node instance using something similar to:
protected void Page_Load(object sender, EventArgs e) { UltraWebTree1.Nodes.Add(new ClonableNode("Node Clone")); } public class ClonableNode : Node { public ClonableNode(string text) : base() { this.Text = text; } public Node Clone() { Node node = new Node(); node.Text = this.Text; node.TargetUrl = this.TargetUrl; node.Selected = this.Selected; return node; } }
Would it be possible to request that a Clone() method be added to the Node class?
I am not sure this is technically possible, since the nature of hierarchical databound controls like UltraWebTree is that they inherit behaviour from their parents - removing / hiding a node will do the same for all it's child nodes.
I guess, you can enumerate all nodes in the original treeview starting from the first sub-root and copy them to another treeview, and use the latter instead. Something along the lines of:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CopyNodeCollection(UltraWebTree1.Nodes[0].Nodes, UltraWebTree2.Nodes); } } private void CopyNodeCollection(Nodes sourceNodes, Nodes destNodes) { foreach (Node node in sourceNodes) { Node childNode = new Node(node.Text, "", "", "", ""); destNodes.Add(childNode); CopyNodeCollection(node.Nodes, childNode.Nodes); } }
<ignav:UltraWebTree ID="UltraWebTree1" runat="server" DefaultImage="" HoverClass="" Indentation="20"> <ClientSideEvents NodeClick="checkParent" /> <Levels> <ignav:Level Index="0" /> <ignav:Level Index="1" /> </Levels> <Nodes> <ignav:Node Text="Root Node"> <Nodes> <ignav:Node Text="Parent Node"> <Nodes> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> <ignav:Node Text="Child Node"> </ignav:Node> </Nodes> </ignav:Node> </Nodes> </ignav:Node> </Nodes> </ignav:UltraWebTree> <br /> <ignav:UltraWebTree ID="UltraWebTree2" runat="server" DefaultImage="" HoverClass="" Indentation="20"> </ignav:UltraWebTree>
Hope this helps.
If we do this way, we will remove all the ChildNodes. how to just hide or remove root node when we display WebTree Control?
mac