Mysql autoincrement field for grid id problem for add row

I have a datastore and dataprocessor linked to a mysql database initiated by:

var myds = new dhtmlXDataStore({
url: “mydata.php”,
datatype: “xml” });
var mydp = new dataProcessor(“mydata.php”);

Then I have a grid sync-ed to the datastore
var mygrid…


And a form bound to the grid
var myform…


All is working fine for manual changes to data for existing records made to either the grid or the form. But when I try to add a new record I have a problem.

The problem is that the id field i’m using for the grid is an autoincrement field supposedly set by mysql on the sql insert. The record is created in the mysql table with correct defaults, the new row appears on the grid and I’m able to auto-select it to appear on the bound form but that autoincrement field value is not making its way back into the id for that grid row.

To add the record I’m using

I have a dataprocessor OnAfterUpdate event
mydp.attachEvent(“onAfterUpdate”, function(id, action, tid, response) {…}

and that is returning
id= a very large number (presumably set by dhtmlx)
action = inserted
tid = the value of the autoincrement field

How does the value of tid get put back into the id of th new row of the grid?

I’ve tried setting the row’s id to tid.

no matter what I do I “Invalid mixing target” errors in the javascript debugger.

Think I found my problem…

Although the dataprocessor “onAfterUpdate” event returns:
id = the dhtmlx set id as a very large number
tid = the new mysql autoincrement number
nothing needs to be done as the new row will have its id set to tid internally.

Now in my case I had a form bound to the grid and was using a grid “onRowAdded” event to select the new row (mygrid.selectRowById(rId, fasle, true, true):wink: for display in the form. However at the time that event is triggered the grid row id is still that very large number and not the mysql autoincremented value.

And so moved the .selectRow to the dataprocessor “onAfterUpdate” event and then the form has the correct row id and saves without errors. :smiley: