dhtmlxTree serializeTree() checkbox problem

Tree with just a folder if serialised and reloaded then gains a checkbox and folder becomes a file



1) Call doOnLoad() dhtmlxTree loadXML to load into tree one folder without a checkbox

2) Call function to

a) serialise the tree to an XML string

b) (re)load the XML string using loadXMLString

the dhtmlxTree now has a checkbox and the folder becomes a file.



1) function doOnLoad() {

tree = leftLayout.cells(“a”).attachTree(“0”);

tree.setImagePath(“codebase/imgs/”);

tree.enableCheckBoxes(true);

tree.loadXML(“xml/tree.xml”);

}



2) function mySerialise {

var x = tree.serializeTree();

tree.deleteChildItems(0);

tree.loadXMLString(x);

}



XML

==

<?xml version="1.0" encoding="iso-8859-1"?>

0


By default tree serializes only id, text and open attributes.


In order to enable serialization of additional parameters you can use setSerializationLevel method:


tree.setSerializationLevel(false,true);


For more details - dhtmlx.com/dhxdocs/doku.php? … ationlevel


But nocheckbox attribute isn’t serialized even in “full serialization” mode. So, this attribute requires modification in the dhtmlxtree_xw.js:


in this file please, locate the second entrance of the out=’<item line and make the following addition in it:


out=’<item


replace with


out=’<item ‘+(itemNode.nocheckbox?(‘nocheckbox=“1” ‘):’’)+’

1 amending dhtmlxtree_xw.js works ie checkbox no longer appears but as expected folder still becomes a file
2 so use tree.setSerializationLevel(false, true); and this also works ie folder stays as folder but unexpectedly checkbox now again appears (with dhtmlxtree_xw.js amended)


Have you made a change in the second out=’<item occurrence ? The issue looks like you made it in the 1st one.

You are correct Alex please accept my apology - I was too eager to try it - it works perfectly thank you.