jQuery UI Widgets › Forums › Grid › updaterow .. duplicate calling

This topic contains 4 replies, has 2 voices, and was last updated by  mallepaddi 12 years, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • updaterow .. duplicate calling #48866

    mallepaddi
    Participant

    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

    updaterow .. duplicate calling #48869

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    updaterow .. duplicate calling #48884

    mallepaddi
    Participant

    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

    updaterow .. duplicate calling #48906

    Peter Stoev
    Keymaster

    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 Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    updaterow .. duplicate calling #49259

    mallepaddi
    Participant

    Hi

    I make ajax call in “cellendedit”, it makes one call.

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.