setting a cel via ajax based on the edits of another cell

Hi,



I am trying to create an AJAX interface whereby the user types in a value in one cell (column 5 in my example) and the program performs a database lookup and populate column 6 with the result.



When I use my grid, I am able to retrieve and update data just fine. That is, until I edit column 5. It performs the lookup, correctly populates column 6 on the screen, but errors when trying to save!



I’ve tried code out of other questions I saw in your knowledgebase such as:

cell.wasChanged

dataproc.setUpdated



But neither work for me. When I disable the AJAX functionality, the save operation works once again.



Can you help?



-Dan Brown





function doOnCellEdit(stage,rowId,cellInd)

{

if(stage==0){

}else if(stage==1){

}else if(stage==2){

if (mygrid.getSelectedCellIndex()==5){

ajaxComputeElev();}

}

return true;

}    

function ajaxComputeElevation()

{

var location=mygrid.cells(mygrid.getSelectedId(),1).getValue();

var measurement_date=mygrid.cells(mygrid.getSelectedId(),2).getValue();

var measurement_time=mygrid.cells(mygrid.getSelectedId(),3).getValue();

var groundwater_measurement=mygrid.cells(mygrid.getSelectedId(),5).getValue();

var url=“gw_events.cfm?method=getelev&site_id=#session.site_id#&location_id=”+location+"&measurement_date="+measurement_date+"&groundwater_measurement="+groundwater_measurement



var loader = dhtmlxAjax.getSync(url);

if(loader.xmlDoc.responseXML!=null)

{

mygrid.cells(mygrid.getSelectedId(), 6).setValue(loader.doSerialization());

//         mygrid.cells(mygrid.getSelectedId(), 6).cell.wasChanged=true;

// dataproc.setUpdated(mygrid.getSelectedId(),true);

}

}

but errors when trying to save!
Can you please provide some more details about the error. ( exact error message of stack trace from firebug )

The code which you are using is correct but the problem may be caused by used event. Dataprocessor attached to onEditCell event as well, and if you are using auto-update mode, immediately after data changing , dataprocessor sends data to server side. You code may be executed before or after it ( in case of “after” scenario it will be executed after data sending, so changes will not be saved ) based on order of initialization command.
To work correctly you need to attach onEditCell event before dataprocessor.init command. ( in such case your code will be called before one of dataprocessor )