I have been experimenting with moving records between lists and then saving the data in the target list.
I got the target list to save by using the SQL_INSERT function in an AJAX callback, which Selwyn recently altered at my request to UPSERT so that existing records are updated and new records are added. This worked brilliantly.
I then got a little more ambitious and added some preprocessing by Javascript to the records in the target list before calling the callback. Firstly a simple set one of the fields in the list to a value from a textbox on the UX, all records to the same value. Using
everything works fine and I am part way to reaching my goal. I then needed to start adding some calculations to the records in the list, so I added the extra code in BLUE below
Although the alert of the calculation works and the records in the list show the TOTAL_QTY as having the correct value for each record the subsequent callback does not fire and therefore the records do not get saved back to the mySQL table.
I have been playing with this for a few hours now and have drawn a complete blank, can anybody spot what is wrong?
I got the target list to save by using the SQL_INSERT function in an AJAX callback, which Selwyn recently altered at my request to UPSERT so that existing records are updated and new records are added. This worked brilliantly.
I then got a little more ambitious and added some preprocessing by Javascript to the records in the target list before calling the callback. Firstly a simple set one of the fields in the list to a value from a textbox on the UX, all records to the same value. Using
Code:
var lObj={dialog.object}.getControl('buildup');var ldata=lObj._data.length; var qty={dialog.object}.getValue('qty'); //alert(qty); for (i=0; i<=ldata; i++){ lObj.updateTableRow(i,{OUTPUT:qty}); } {dialog.object}.saveListEdits('buildup',{rows: 'allRows'});
Code:
var lObj={dialog.object}.getControl('buildup');var ldata=lObj._data.length; var qty={dialog.object}.getValue('qty'); //alert(qty); for (i=0; i<=ldata; i++){ lObj.updateTableRow(i,{OUTPUT:qty}); [COLOR=#0000ff]var constant=lObj.getData(i).CONSTANT;[/COLOR] [COLOR=#0000ff] var waste=lObj.getData(i).A_WASTE;[/COLOR] [COLOR=#0000ff] //alert(qty*constant*(1+(waste/100)));[/COLOR] [COLOR=#0000ff] lObj.updateTableRow(i,{TOTAL_QTY:qty*constant*(1+(waste/100))});[/COLOR] } {dialog.object}.saveListEdits('buildup',{rows: 'allRows'});
I have been playing with this for a few hours now and have drawn a complete blank, can anybody spot what is wrong?
Comment