Check documentation for the latest version of dhtmlxSuite Data Scheme DHTMLX Docs

Data Scheme

Data scheme allows setting a default scheme for data records of DataStore. So in cases when you add an empty record to DataStore (data.add({})), the record will be populated with the values set by the scheme.

myDataStore.data.scheme({
    name:"Unknown",
    gender:"male",
    age:25,
    department: "Unknown"
});
//will add {name:"Unknown",gender:"male",age:25,department:"Unknown"} record
myDataStore.add({});

There are also 2 special keys you can use in a scheme:

  • $init - called during initial object creation

    Let's assume you want to populate a combo with data from some column of db (e.g. column 'name' with the names of departments). To make the combo recognize the names of departments as options, combo should get data as sets of 'text' and 'value' parameters. In this situation the $init key is useful:
     myDataStore.data.scheme({
        $init:function(obj){
            obj.value = obj.name;  // 'name' is the name of the column from the db
            obj.text = obj.name;
        }
     });
  • $update - called each time after data changing
    myDataStore.data.scheme({
        $update:function(obj){ 
            obj.text = obj.name + " " + obj.number;
        }
    });
Back to top