Problem setting cell value from dataprocessor

I use the addRow() method of the grid to insert a new row. After adding the row I call the sendData() method of the dataprocessor - this creates a new row in my database.

I have a hidden column in the grid (_c0) for storing record id’s from the database - these are primary keys and I use them during updates via the dataprocessor.

When I add a new row I cannot write the TID returned from the dataprocessor to _c0, and therefore cannot update the newly added row.

Please see below “Client Side Code”, “INSERT LOG”, and “UPDATE LOG” for more detail. The update log shows that 166_c0 does not contain a value - I cannot seem to set this value.

My Question is: How can I retrieve the TID from the dataprocessor and populate 166_c0 using javascript?

– Client Side Code –

function insertPackageOrder()
    {   
      rowId = (new Date()).valueOf(); 
      var newId = mygrid.addRow(rowId,['','9999','0','0.00','F','','','','Desc','0.00','0.00','0.00','0.00','','0.00'],mygrid.getRowIndex(mygrid.getSelectedId()));
      mygrid.selectRow(mygrid.getRowIndex(newId),false,false,true);

      myDataProcessor.sendData();
      
      return true;
      
    }

** INSERT LOG **
Log:
row 1275441561754 marked [inserted,valid]
Initiating data sending for 1275441561754
Initiating data sending for all rows
Sending all data at once
Server url: XML/updateMDSW_PO_EO.php?editing=true parameters
1275441561754_gr_id=1275441561754
1275441561754_c0=
1275441561754_c1=9999
1275441561754_c2=0
1275441561754_c3=0.00
1275441561754_c4=F
1275441561754_c5=
1275441561754_c6=
1275441561754_c7=
1275441561754_c8=Desc
1275441561754_c9=0.00
1275441561754_c10=0.00
1275441561754_c11=0.00
1275441561754_c12=0.00
1275441561754_c13=
1275441561754_c14=0.00
1275441561754_!nativeeditor_status=inserted
ids=1275441561754
Initiating data sending for all rows
Sending all data at once
Server url: XML/updateMDSW_PO_EO.php?editing=true parameters
Server response received details

<?xml version="1.0" encoding="iso-8859-1"?>

Action: inserted SID:1275441561754 TID:166
row 1275441561754 unmarked [updated,valid]

** UPDATE LOG **

row 166 marked [updated,valid]
Initiating data sending for 166
Initiating data sending for all rows
Sending all data at once
Server url: XML/updateMDSW_PO_EO.php?editing=true parameters
166_gr_id=166
166_c0=
166_c1=1234569999
166_c2=0
166_c3=0.00
166_c4=F
166_c5=
166_c6=
166_c7=
166_c8=Desc
166_c9=0.00
166_c10=0.00
166_c11=0.00
166_c12=0.00
166_c13=
166_c14=0.00
166_!nativeeditor_status=updated
ids=166
Server response received details

<?xml version="1.0" encoding="iso-8859-1"?>

Action: update SID:166 TID:166
row 166 unmarked [updated,valid]

When I add a new row I cannot write the TID returned from the dataprocessor to _c0
You can use DataProcessor event to check if row was inserted or deleted at the server side and change value of the _c0 cell with getValue method. Please find more information about DataProcessor events here
docs.dhtmlx.com/doku.php?id=dhtm … sor:events
dhtmlx.com/docs/products/dht … vents.html

Thanks Olga, that’s perfect.

For reference this is the additional code I required:

myDataProcessor.attachEvent("onAfterUpdate",function(sid,action,tid,xml_node){
                     
           //update cell zero with the Temporary ID (this contains mysql_insert_id)
           mygrid.cells(tid,0).setValue(tid);
           
           return true;
        });