DHTMLX Docs & Samples Explorer

Serialization, Caching and Removing Tree

Serializing Tree

The user can get an XML representation (as a string) of the tree using method serializeTree():

    <script>
        tree.serializeTree();
    </script>
 

Also there is the possibility to return the tree as a JSON string like this:

    <script>
        tree.serializeTreeToJSON();
    </script>
 

Setting Serialization Level

XML serialization can be easily configured in the following way:

    <script>
        tree.setSerializationLevel(userData,fullXML,escapeEntities,userDataAsCData,DTD);
    </script>
 

The parameters are as follows:

  • userData - enable/disable user data serialization;
  • fullXML - enable/disable full XML serialization;
  • escapeEntities - convert tag brackets to related html entities;
  • userDataAsCData - output user data in CDATA sections;
  • DTD - if specified, then set as XML's DTD.

Preventing Caching in IE

The user can prevent caching in IE by adding random value to URL string with the help of method preventIECaching():

    <script>
        tree.preventIECaching(true|false); // false by default
    </script>
 

Registering XML Entity

There is the possibility in dhtmlxTree to register an XML entity for replacement of special symbols while initialization of the tree (default ones are: ampersand, “less then” and “greater then” symbols):

 
      <script>
          tree.registerXMLEntity(rChar,rEntity);
      </script>
 
 

The parameters are the following:

  • rChar - source char;
  • rEntity - target entity.

Removing Tree

There is a simple method that allows the user to remove the tree completely and to clear memory:

    <script>
        tree.destructor();
    </script>