Hi , I am using a dhtmlxgrid with mysql as a backend DB. The response from the server contains the new ID that was created as autoincrement. The problem starts with commands that need to be executed right after adding a new row (e.g addRow & copyRowValues) - since it’s async, the id of the new added row has a different ID until the response is received and the delay is causing a lot of troubles in my application.
This piece of code doesn’t work either, since it passes a wrong rid
myDataProcessor.setOnBeforeUpdateHandler(function(rid){
bar= document.getElementById(“progress”);
bar.innerHTML=“Saving data, please wait…”;
mygrid.lockRow(rid,true);
return true;
});
myDataProcessor.setOnAfterUpdate(function(rid){
mygrid.lockRow(rid,false);
bar= document.getElementById(“progress”);
bar.innerHTML="";
return true;
}
The build i am using is v.1.6 build 80512
I need to make sure that the next command after addRow is executed only after the new row was added and the response was received. Can you please help?
Thanks in advance
Gabriel
code attached to setOnAfterUpdate event receives not only initial row id value, but new ID as well
myDataProcessor.setOnAfterUpdate(function(sid,action,tid){ //tid - new ID for insert operation
mygrid.lockRow(tid,false);
bar= document.getElementById(“progress”);
bar.innerHTML="";
return true;
}
>>I need to make sure that the next command after addRow is executed only after the new row was added
There are two ways
- break the code in two separate functions, and call second one from setOnAfterUpdate event
- switch dataprocessor to sync. mode
dhtmlxdataprocessor.js , line 226
var a2=new dtmlXMLLoaderObject(this.afterUpdate,this,true);
can be changed to the
var a2=new dtmlXMLLoaderObject(this.afterUpdate,this,false); //sync mode