Check documentation for the latest version of dhtmlxSuite Data Updating HowTos DHTMLX Docs

Data Updating HowTos

How can I alter the default styles set for responses?

You can alter the default styles for each state, like:

dp.styles.error = ""; //avoids a special style for the 'error' response
//you should write it on the client side (in your HTML file)
//dp - dataProcessor object

How can I avoid updating certain field(s)?

To remove some field from updating you can use the following technique:

//write it before '$grid->render_table'
function filter_set($action){
   $action->remove_field("id"); //the named field won't be included in CRUD operations
$grid->event->attach("beforeProcessing", filter_set);

How can I change default data processing while updating?

To affect the default data processing either on the server- or client-side you should use either dataProcessor or dhtmlxConnector events. For more details, see the chapter 'Changing default processing' in 'Client-side requirement - dataProcessor'.

How can I set a custom status of the operation?

By using the set_status() method you can set status (custom or another predefined) of operation. Using the defineAction() method of dataProcessor you can assign the appropriate processing for this status.

return true;// return false to cancel default data processing at all

How can I terminate any further processing?

Calling the success() method you terminate any further action processing, i.e. data updating will be stopped and considered as finished.

function my_update($data){
   $data->success(); // marks an operation as finished 

How can I change values before saving?

To customize values before saving you should use the server-side events stated below:

function my_update($data){

For more information, see the 'Using server-side events' chapter in 'Making queries' guide.

How can I implement transactions?

The connector allows using transactions for INSERT/UPDATE/DELETE operations (make sure that the used DB engine has support for transactions).

To activate transaction mode use the set_transaction_mode() method. For more details see the chapter 'Transactions' in 'Making queries' guide.

$conn->sql->set_transaction_mode("global"); //for all records inside of single request
$conn->sql->set_transaction_mode("record");// for each record in request

How can I link dataProcessor with connector?

To link dataProcessor with connector you should specify the connector file as a parameter of dataProcessor constructor:

dp = new dataProcessor("myconnector.php");

How can I update data on the server side?

To update data on the server side, you should initialize dataProcessor on the client side and link dhtmlxConnector to it. The default updating will be done automatically. For more details, see the guide 'Client-side requirement - dataProcessor'.

How can I save data changes made in form (simple way)?

dhtmlxConnector automatically executes CRUD operations for next patterns:

//to get data of a DB record
   GET: connector.php?action=get&id={some}
//to delete data of a DB record
   GET: connector.php?action=delete
//to update data of a DB record
   GET: connector.php?action=delete
   POST: id={some}&property_name={value}
//to insert a new record to DB
   GET: connector.php?action=insert
   POST: property_name={value}

For more details see the guide 'Saving data changes made in form'.

Back to top