How to create your own data type?
DataDriver is an object that defines a data type.
DHX gives at your disposal 5 main drivers:
Therewith, you can specify your own data type - create your own driver.
The structure of creation is the following:
dhx.DataDriver.some={ //some - the name of the type toObject:function(text,xml){ ... return text; }, getRecords:function(data){ var result = []; ... return result; }, getDetails:function(data){ var result = {} ... return result; }, getInfo:function(data){ return { _size:some, _from:other }; } };
For a start, we have some data that we want to use as a new data type. The first thing we need to make with this data - conversion into an intermediate object (an object that will be used as an input parameter in the other functions).
So, our first step - toObject(text, xml) function. The function is called after data loading or directly in the parse method and returns the intermediate data object.
Then, we form an array of records using data from our intermediate object.
The second step - getRecords(data) function.
Having an array of records we need to specify a set of properties for each single record.
The third step - getDetails(data).
The last action has sense just for dynamic data loading scenarios. It's a function that gets count of data and position at which new data needs to be inserted.
The fourth step - getInfo(data). The function returns count of data and the appropriate position mentioned above: '0' if a value is unknown or unnecessary.
So, making these four or even three steps you can specify any data type and then use it while developing.