jQWidgets Forums

jQuery UI Widgets Forums Grid Adding rows to a grid – duplicates problem

This topic contains 1 reply, has 1 voice, and was last updated by  andy8 11 years, 8 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • andy8
    Participant

    Hi All,

    I am adding new rows to the grid using this code:

    	var row = {};
    var res = data.res;
    $("#curr_wallet").jqxGrid('beginupdate');
    $.each(res, function (key, val) {
    var newf = val;
    row['id'] = newf[0];
    row['fund'] = newf[1];
    $("#curr_wallet").jqxGrid('addrow', null, row);
    });
    $("#curr_wallet").jqxGrid('endupdate');

    The problem is that it adds identical rows and each subsequent new row overwrites rows already added to the grid. In other words, if I add 4 rows to the grid, all 4 last rows are identical and equal to the last row in the array.

    What am I missing here?

    thanks


    andy8
    Participant

    The update:

    this code is working…. seems to be related to object referencing for multiple rows.

      var rows = [];
    var res = data.res;
    $.each(res, function (key, val) {
    var newf = val;
    var serObj = {
    id: newf[0],
    fund: newf[1]
    };
    rows.push(serObj);;
    });
    $("#curr_wallet").jqxGrid('beginupdate');
    $("#curr_wallet").jqxGrid('addrow', null, rows);
    $("#curr_wallet").jqxGrid('endupdate');
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.