jQWidgets Forums

jQuery UI Widgets Forums Grid error in getting boundrows

This topic contains 3 replies, has 2 voices, and was last updated by  mallepaddi 11 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • error in getting boundrows #49171

    mallepaddi
    Participant

    Hi

    There are two grids displaying side by side, and intention is to add products from left to right and show up total price of all products on toolbar of right grid.

    We are not adding products directly to grid using “addrow” instead we send data to back end and then showing them into grid.

    using two adapets, first is when loading grid for first time and second is to update grid data when addition / deletion / updation to data happens.

    data being added to right grid but tocalculate sum, it always returns zero for following ..

    var rows = $(‘#ordercartgrid’).jqxGrid(‘getrows’);
    var rows1 = $(‘#ordercartgrid’).jqxGrid(‘getdisplayrows’);
    var rows2 = $(‘#ordercartgrid’).jqxGrid(‘getboundrows’);

    alert(‘getrows : ‘ + rows.length);
    alert(‘getdisplayrows : ‘ + rows1.length);
    alert(‘getboundrows : ‘ + rows2.length);

    =====================================================
    var cartsource = {
    datafields: cartDataFields,
    deleterow: function (rowid, commit) {
    commit(true);
    },
    addrow: function (rowid, rowdata, position, commit) {
    commit(true);
    },
    updaterow: function (rowid, rowdata, commit) {
    commit(true);
    },
    datatype: “json”,
    url: ‘/dataServlet?action=GetProducts’,
    id: ‘serialNo’
    };

    cartdataAdapter = new $.jqx.dataAdapter(cartsource, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { alert(‘Error loading “‘ + cartsource.url + ‘” : ‘ + error);}
    });

    var cartSourceFromMemory = {
    datafields: cartDataFields,
    deleterow: function (rowid, commit) {
    commit(true);
    },
    addrow: function (rowid, rowdata, position, commit) {
    commit(true);
    },
    updaterow: function (rowid, rowdata, commit) {
    commit(true);
    },
    datatype: “json”,
    url: ‘/dataServlet?action=GetProductsFromMemory’,
    id: ‘serialNo’
    };

    cartdataAdapterFromMemory = new $.jqx.dataAdapter(cartSourceFromMemory, {
    downloadComplete: function (data, status, xhr) { },
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { alert(‘Error loading “‘ + cartSourceFromMemory.url + ‘” : ‘ + error);}
    });
    ===================================================================

    during page instialization :
    $(‘#ordercartgrid’).jqxGrid({ source: cartdataAdapter });

    when record added :
    calling second adapter when ajax call success
    function addProductsToCart(e){
    ………….
    $.ajax({
    cache: false,
    url: ‘/dataServlet?action=Product_Add’,
    data: {
    rowData: JSON.stringify(datarows)
    },
    type: “POST”,
    success: function (data, status, xhr) {
    $(‘#ordercartgrid’).jqxGrid(‘clear’);
    $(‘#ordercartgrid’).jqxGrid({ source: cartdataAdapterFromMemory });
    },
    error: function (jqXHR, textStatus, errorThrown) {
    alert(errorThrown + ” / Error while adding product”);
    },
    complete:function (jqXHR, textStatus) {
    $(‘#ordercartgrid’).jqxGrid(‘clearselection’);
    $(‘#ordercartgrid’).jqxGrid(‘refreshdata’);

    $(‘#productgrid’).jqxGrid(‘clearselection’);
    $(‘#productgrid’).jqxGrid(‘refreshdata’);

    setTotalProductPriceInOrder();
    }
    });

    Any idea why i get ZERO records, so i could not iterate to find total price of all products.

    Please help.

    Thanks

    error in getting boundrows #49173

    Peter Stoev
    Keymaster

    Hi mallepaddi,

    It is possible that when you get the bound rows, the data binding operation could still be not yet completed. I suggest you to use the loadComplete callback function of jqxDataAdapter or the “bindingcomplete” event of jqxGrid and inside the callback or event handler, call the appropriate Grid methods.

    Best Regards,
    Peter Stoev

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

    error in getting boundrows #49174

    mallepaddi
    Participant

    Hi

    Error still the same if i do the same operation even after 30 min , binding would have completed by that time.

    I suspect it could be different issue.

    FYI – same error even calling at
    $(‘#ordercartgrid’).on(‘bindingcomplete’, function (event) {
    setTotalProductPriceInOrder();
    });

    Thanks

    error in getting boundrows #49184

    mallepaddi
    Participant

    HI

    It works for “loadComplete” event.

    But how to make different actions based on ADD / UPDATE / DELETION.

    after each operation i need to load fresh data from server but need to perform different action based on operation.

    How do we differentiate ?

    Thanks

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

You must be logged in to reply to this topic.