DHTMLX Docs & Samples Explorer

Simultaneous Server Update

dataProcessor Module

Common tree manipulations, like drag-n-drop (including d-n-d between trees), removing item, inserting item, or updating item's label, can be simultaneously reflected in server database now (since v.1.3) using dataProcessor module.

Main features of this module are:

  • An updated/inserted item is marked with bold text, a deleted one - with line-through;
  • You can define the mode for data processing (automatic|manual).

Updated|deleted items' data is sent to the server to the specified URL (we call it serverProcessor). serverProcessor should return simple XML of the specified format to let the tree know about successful or not successful processing. All necessary after-save procedures will be done automatically.

Enabling dataProcessor Module

To enable this feature, the user should do the following:

  • Include dhtmlxdataprocessor.js file to the page;
  • Create dataProcessor object for the tree;
  • Initialize dataProcessor.
    <script src="../codebase/dhtmlxdataprocessor.js"></script>
        myDataProcessor = new dataProcessor(serverProcessorURL);
        myDataProcessor.init(treeObj); // tree object to assign dataProcessor to, mandatory

The mandatory parameter for dataProcessor is:

  • serverProcessorURL - URL of the file that will process incoming data. If our server-side routines is used, “dhtmlxDataProcessor/server_code/PHP/update.php?ctrl=tree” should be indicated.

Server-Side dataProcessor Handling

Using server-side dataProcessor, the user should bare in mind the following:

  • All data comes in GET scope:
    • tr_id - node id;
    • tr_order - node sequense on the level;
    • tr_pid - parent id;
    • tr_text - node text(label);
    • Userdata blocks - are passed with their names.
    • !nativeeditor_status - values can be as follows:
      • “inserted” - item is inserted;
      • “deleted” - item is deleted;
      • “updated” or item doesn't exist - item is updated.
  • serverProcessor should return valid XML of the following format:
    <action type='insert/delete/update' sid='incomming_node_ID' tid='outgoing_node_ID'/>

In the above mentioned snippet, incomming_node_ID and outgoing_node_ID may be different for insert action only, but they are equal for other actions.