Check documentation for the latest version of dhtmlxSuite Using Dataprocessor DHTMLX Docs

Using Dataprocessor

Common TreeView manipulations like drag-n-drop, removing an item, adding a new item or updating an item's label can be simultaneously reflected in the server database using DataProcessor.

The data of the updated/deleted items is sent to the server to the specified URL (we call it serverProcessor).

The serverProcessor should return a simple XML or JSON of the specified format to let the TreeView know about successful or unsuccessful processing. All the necessary after-save procedures will be done automatically.

Enabling DataProcessor

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

  • Create DataProcessor object for TreeView;
  • Specify the path to your REST server in the dataProcessor's constructor
  • Initialize DataProcessor and attach it to the Treeview object
myTreeView = new dhtmlXTreeView("treeviewObj");
var dp = new dataProcessor("data.php");
dp.init(myTreeView); // treeview object to assign DataProcessor to, mandatory
  • call the setTransactionMode method with the "REST" value

Server-Side DataProcessor Handling

Using the server-side DataProcessor the user should bear in mind the following:

The response can be any valid JSON object.

The full server response should contain the following properties:

  • action - the type of the operation;
  • sid - the original event ID;
  • tid - the ID of the event after the operation.

There are 5 predefined types of response:

  • updated;
  • inserted;
  • deleted;
  • invalid;
  • error.

So, an example of response can be as follows:


To change the id of the event while updating, use the tid property.

Back to top