Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stephen on Nov 10, 2009 08:57
open dhtmlx forum
dhtmlxTree - serializeTree() a tree that uses setXMLAutoLoading() only 'works' if node opened.

If a node is opened when you serializeTree() a tree that uses setXMLAutoLoading() and then load it back with loadXMLString() then the nodes opened are seen with the [-] symbol but any node not opened that has children loses the [+] symbol.

The problem - if I use setXMLAutoLoading and loadXML then dhtmlxTree shows the tree with a closed node that has a [+] icon to indicate it has children. If I serialise the tree and load it back using loadXMLString() then the tree no longer has the [+] icon ie its as if its only loading the first level. But if nodes are opened prior to the serialisation then when loaded back those nodes are still seen to be open and can be ie loaded more than one level but all [+] symboils are lost.

1) function doOnLoad() {
tree.setXMLAutoLoading(<create xml file per level.php>);
tree.loadXML(<create xml file per leve.phpl>); // get first level
:
}

2) function mySerialise {
tree.setSerializationLevel(false, true);
var x = tree.serializeTree();
tree.deleteChildItems(0);
tree.loadXMLString(x);
}

Answer posted by Alex (support) on Nov 10, 2009 09:34

There was a bug in the serialization with autoloading. The fix will be sent by  email (it will contain the solution for nocheckbox attribute). 

Answer posted by Stephen on Nov 17, 2009 03:49
Fix works but it does not pick up style content in this case text color and background color. I switched to aCol but does mean background color is lost.
Answer posted by Alex (support) on Nov 17, 2009 05:36

Unfortunately "style" attribute can not be serialized. 

The possible solution is userdata. It is additional node infromation that can be set either in xml:

<item ....><userdata name="style">background-color:red;</userdata></item>

or by tree API:

tree.setUserData(itemId,"style","background-color:red;");

Userdata can be serialized (the 1st parameter of setSerializationLevel method should be true). So you will get the style (or any other data) in the serialized string.