DHTMLX Touch documentation

Api:

GlobalStore:

  • lockItemEdit(id) - locks item edition
  • unlockItemEdit(id) - unlocks item edition
  • backup(id, to_delete) - makes item backup
  • restore(id) - restores item previous data if its dump exists
  • apply(id) - apply changes (clear item dump)
  • getBackupData() - returns original data (before edit)
  • clearBackup(id) - clear backup for item with specified id or all backups if id isn't specified
  • getFormData(form) - returns data from form (dhtmlxForm object) according form scheme
  • getGridData(grid, rId) - returns row data from grid by rId or array of rows (rId isn't specified) according grid scheme
  • endEdit() - ??
Events:

DataStore:

  • onBeforeAdd - before add item, blockable
  • onBeforeUpdate - before update item, blockable
  • onBeforeDelete - before remove item, blockable

GlobalStore:

  • onEdit - before changing cursor if current data and data in backup aren't the same
dhtmlxGlobalStore initialization:
store = new dhx.dhtmlxGlobalStore({
	backupMode: "cursorchange",
	onEditChangedOnly: false
});

backupMode - list of events when data will do backup
onEditChangedOnly - to set as parameter in onEdit callback hash of current item data or hash of only changed data

Validation

To check if data is correct you can add validation rules to GlobalStore. After data changing data will validated by this rules and if data incorrect event onInvalid occurs.

Rules addition:

store.setValidation(propName, rule, type);
  • propName - item property name which has to be validated
  • rule - function which takes property value as argument and return true or false or RegExp object
  • type - if you use regexp rule this parameter should be “regexp” or can be missed otherwise

Event:

store.attachEvent("onInvalid", function(id, value, prop, rule) {
	var inv = {
		id: id,
		value: value,
		prop_name: prop,
		rule_name: rule
	};
 
	console.log("Invalid data:");
	console.dir(inv);
});
  • id - invalid item id
  • value - invalid value
  • prop - name of invalid property
  • rule - name of rule

Manual validation:
If you want to call item validation you should use validateItem() method:

store.validateItem(id);
  • id - id of item to validate (optional, if not specified current cursor is used)

Method returns true if all properties value are valid according all added rules.