Hi.
I'm checking out how much of an effort it is to upgrade from our current UltraWebTree 11.1 to WebDataTree 12.2.
The challenge is that the existing code uses ReadXmlText to bind/load data into the control. I do not see a similar method in WebDataTree.
The current XML format we use is not tied to a schema; so what would be the easiest way to use this data format in the WebDataTree control.
Code snippet of current implementation...
XmlTextReader resultReader = new XmlTextReader(XMLString,XmlNodeType.Document,null); ultraWebTree.ReadXmlText(resultReader,true,false);
The XMLString is something like... (I got one of the longest I could!)
Quote 189 Type of Business Class of Business Objects of Interest Object Mame 564 Joint Membership 0 Co-Assured 0 Member David Lloyd 6079811 Company name 60811 Contributors 0 Contract Rules 13 Contract for Object 1 24 Rule Rule 1 Clauses PPP111 CLause 1 for Object 1 82 CLause 2 for Object 1 83 Rule 2 for Object 1 Clauses PPP222 CLause 1 for Object 1 82 CLause 2 for Object 1 83 Payment Amount Assessment 1 Member Name 0 David LLoyd
Hello Ajeesh,
Thank you for posting in our forum.
There’s no similar method for the WebDataTree. The WebDataTree doesn’t have any presets like the UltraWebTree had.For the UltraWebTree loading the xml definition in this manner was possible since it supported the saving and creating of presents in that specific xml format.
For the WebDataTree you could use a xml data source to populate the nodes however it will have to be in a different format than what you currently have in your xml file.There’s an example and explanation on how you can set up an xml data source for the WebDataTree here: http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebDataTree_Binding_WebDataTree_to_an_Xml_Data_Source.html
Let me know if you have any questions or concerns.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
We had been using UltraWebTree.ReadXmlText() to populate the tree view control, by passing the XML containing the node text, value and style elements, something like…
<Nodes>
<Node>
<Text>Joint</Text>
<Tag>0</Tag>
<Style>
<ForeColor>#FFFC0033</ForeColor>
</Style>
<Nodes />
</Node>
</Nodes>
We are finding it difficult to achieve the same styling functionality in the WebDataTree, with a source xml something like the below…
<Node Text="Proposal" Tag="153">
<Node Text="Entry1" Tag="">
<Node Text="Entry1-1" Tag="">
<Node Text="Entry1-1-1" Tag="">
<Node Text="TestName" Tag="462">
<Node Text="Joint" Tag="0" Style="red">></Node>
<Node Text="Co" Tag="0"></Node>
<Node Text="Member" Tag=""></Node>
<Node Text="Mortgage" Tag="0" Style="red">></Node>
One if the solutions we can think of now is use the style attribute from the xml in a JS function to set the cssclass attribute.
One of the key challenges we are now facing in handling this in the client side JS function is that there isnt much info online about arguments of event-handlers
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=Infragistics4.Web.v12.2~Infragistics.Web.UI.NavigationControls.DataTreeClientEvents_members.html
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=WebDataTree~Infragistics.Web.UI_namespace.html
These 2 links help me get a list of the client-side event names, but not much information about the arguments of the event-handlers.
For instance, consider the below JS function which gets called on the NodeExpanded client event…
function WebDataTree1_NodeExpanded(sender, eventArgs)
I could not find any info on what functions and properties can be used for the sender or the eventArgs arguments, like…
eventArgs.getNode().get_childrenCount()
Can you share some link where we can get these details?
This will be useful when I try to implement an event for which you haven’t shared samples, like Initialize. I need to get all nodes in this function.
Hello Ajeesh ,
The “sender” will always be the WebDataTree object since that will be the object that raises the event.
The eventArgs depend on the specific event.
For example the NodeExpanded event will take an event argument of type DataTreeNodeEventArgs. If you open that object’s members:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=WebDataTree~Infragistics.Web.UI.DataTreeNodeEventArgs_members.html
You’ll see what methods you have available. In this case you have only getNode() which will return the related node object for the event.
Other events take other types of event arguments for example the SelectionChanging event:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=Infragistics4.Web.v12.2~Infragistics.Web.UI.NavigationControls.DataTreeClientEvents~SelectionChanging.html
Takes an eventArgument of type DataTreeSelectionEventArgs:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.2/CLR4.0/?page=WebDataTree~Infragistics.Web.UI.DataTreeSelectionEventArgs_members.html
Which has other available methods like the getNewSelectedNodes() method.
To check exactly what type of event arguments each event takes you can open the event specification from the list:
In it there’s a code example and in it at the top you’ll find a comment that describes what the sender and event arguments are. Once you find the type of the argument you can search the documentation and find the members of that type.
Let me know if you have any questions.
Thanks Maya.
I guess the confusion can be attributed to the fact that the Initialize property can be used as an event, but there isnt an example for it.
something like...
Initialize="xwdTree_Init"
and a function like...
function xwdTree_Init(sender, eventArgs)
function
xwdTree_Init(sender, eventArgs)
I'm basically trying to get all nodes in the Initialize event and check if I can set the cssClass from the style attribute in the xml.
Any suggestions for this?
You can loop through the nodes and set the style or the ClassName if you want. For example :
function WebDataTree1_Initialize(sender, eventArgs)
{ for (var i = 0; i < sender.getNodes().get_length(); i++) {
var currentNode = sender.getNodes().getNode(i);
currentNode.get_element().style.backgroundColor="Blue";
loopChildren(currentNode);
}
function loopChildren(node) {
for (var k = 0; k < node.getItems().get_length(); k++) {
var currentNode = sender.getNodes().getNode(k);
This will go recursively around all the nodes you have loaded in the tree and will set the background color to blue.
So using this you could loop through each node and set any style you want for it.
Developer Support Engineer II
Thanks for this Maya!
Incidentally we had come up with a similar recursive solution a few hours before your post!
We have some business rules for setting the style, which are part of an xslt; for instance, the xml i shared has some nodes marked with a style attribute.
So for such a source xml, can you suggest some ways to pull this attribute value in the Initialize event?
One of the solutions is to store this Style attribute in the ValueField (along with the actual value) of the node. It would be good if we can avoid this though, so that we dont have to split the actual value and Style info at both client and server side!
Anything on this yet?
Hello Jaydeep ,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Hello Jaydeep,
Wouldn’t it be easier in your case to set the css classes on the server side?
The DataTreeNode has a CssClass so you could loop on the server side trough the nodes and set that property.
In this way you would only need to load the xml file on the server side. Otherwise you would also have to load the xml file on the client as well.
You could for example load your file in a XmlDocument and loop trough the ChildNodes to get the Style attribute and set them to the CssClass property of the related DataTreeNodes.
Let me know if you have any questions or if you need further assistance.