dataProcessor

Overview

In this chapter you'll know about dataProcessor, a library that will help you to process data and 'communicate' with server-side backend.

Functionality

dataProcessor provides ready functionality for:

  • Validation - validation can be applied just to form's object but dataProcessor lets to set the needed validation rules to any component

Initialization

dataProcessor can be initialized in two ways:

Full form

var dp = new dhx.DataProcessor({
			master:$$('mylist'),
			url:"validate.php"
});

Short form

var dp = dhx.dp("mylist", "validate.php"); // if a dataprocessor for a component already exists, it'll be used. If not - the new one will be created.

In both cases constructor takes the same parameters. The following are commonly used:

  • master - (id) specifies a main data source.
    It can be both some independent data source and one of components operated on data (e.g. grid).
  • url - (url) defines the path to the file which will get change requests.
    It's an optional parameter and if you don't deal with server-side you needn't to use it.
    In other words, it's a path to server (if you use dhtmlxConnector, a path to its file can be set as this parameter. In this case, dhtmlxConnector will do all the server work).

Saving

DataProcessor lets to save data back to DB. During dataprocessor's init you can specify the appropriate server file in the second parameter of an object constructor ('url'). The simplest solution will be to use dhtmlxConnector. Also it possible to implement your custom server side code ( check dhtmlxConnector documentation for protocol details )

var dp = new dhx.DataProcessor({
			master:$$('mylist'),
			url:"data.php"
});

After that, when you need to send data back to server you should call the send method

//will save all changes in the component back to DB
dp.send();

API Reference