jQuery UI Widgets › Forums › Grid › updaterow .. duplicate calling
Tagged: grid row editing
This topic contains 4 replies, has 2 voices, and was last updated by mallepaddi 12 years, 9 months ago.
-
Author
-
Hi,
I was using my grid for displaying list of products and user can edit Quantity field.
now “updaterow” is being called twice, one with old quantity and second call with updated quantity,
Please help how to avoid first call having old valie.
cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) {
var datarow = $(‘#cartgrid’).jqxGrid(‘getrowdata’, row);
$(‘#cartgrid’).jqxGrid(‘setcellvalue’, row, ‘totalPrice’, datarow.productPrice * newvalue);
setTotalProductPriceInCart();
},
======================================================updaterow: function (rowid, rowdata, commit) {
alert(‘updaterow’);
$.ajax({
cache: false,
url: ‘/dataServlet?action=Cart_Update’,
data: {
rowData: JSON.stringify(rowdata)
},
type: “POST”,
success: function (data, status, xhr) {
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown + ” / Error while updating product : ” + rowid);
}
});
commit(true);
},
========================Thanks
Hi mallepaddi,
I think that should be expected because in the provided code, there is: $(‘#cartgrid’).jqxGrid(‘setcellvalue’, row, ‘totalPrice’, datarow.productPrice * newvalue); when the value of a cell is being changed. That will result in 2 calls.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi
Changing code as below doesn’t work either, making duplicate calls ..
cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) {
var datarow = $(‘#cartgrid’).jqxGrid(‘getrowdata’, row);
datarow.totalPrice = datarow.productPrice * newvalue;
//$(‘#cartgrid’).jqxGrid(‘setcellvalue’, row, ‘totalPrice’, datarow.productPrice * newvalue);
$(“#cartgrid”).jqxGrid(‘updaterow’, row, datarow);
},Is there a way that we can stop making 2 calls when updating row.
Thanks
Hi mallepaddi,
That’s the same. It does not matter whether “setcellvalue” or “updaterow” is called. “cellvaluechanging” is a callback function which is called when the value of a cell is changing. That usually happens after editing. So, you have 1 automatic call by the Grid and in “cellvaluechanging” you make an additional call of “setcellvalue” or “updaterow”. The result as it should be expected would be a call of the source object’s “updaterow” callback function.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi
I make ajax call in “cellendedit”, it makes one call.
Thanks
-
AuthorPosts
You must be logged in to reply to this topic.