jQWidgets Forums

jQuery UI Widgets Forums Grid get all data in Grid

This topic contains 6 replies, has 3 voices, and was last updated by  NHHL 12 years, 11 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • get all data in Grid #5084

    NHHL
    Member

    Hi Peter!

    I have a question, how can i get back all data in grid after i has change some rows? name of json var hold data in grid?
    I want using it for another process.

    get all data in Grid #5085

    Peter Stoev
    Keymaster

    Hi NHHL,

    When you change a row, add a row or delete a row, the Grid calls the appropriate callback functions when they are defined. In that functions, the changed rows are coming as parameters. Take a look at the implementation of this sample: createremoveupdatedata.htm. The Grid call’s the source object’s addrow, deleterow or updaterow functions when a row in the UI is added, deleted or updated. In addition, to get the data of any row in the Grid, use the ‘getrowdata’ method.

    For example:

    // @param row index.
    var data = $('#grid').jqxGrid('getrowdata', 0);

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    get all data in Grid #5099

    NHHL
    Member

    Hi again!

    I know method ‘getrowdata’ but… it only get 1 row. I want get all rows.
    This is my schema:

    1. load json data from mysql to grid (ok)
    2. change value on row (ok)
    3. save grid to json file (????)

    i dont know solution for step 3?

    Thanks!

    get all data in Grid #5111

    Peter Stoev
    Keymaster

    Hi NHHL,

    jqxGrid does not currently support export to JSON or any other data format.
    If you want to get the loaded records into the Grid, you can do this:

    var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function () {
    var records = dataAdapter.records;
    }
    });

    Another solution for getting all rows is to call the Grid’s getrowdata method for each row index. The number of rows can be retrieved from the dataAdapter – var length =dataAdapter.records.length;

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    get all data in Grid #5129

    jonj
    Member

    NHHL,

    Just do this and convert to JSON:

    http://www.jqwidgets.com/community/topic/traversing-grid-content/

    var griddata = $('#jqxGrid').jqxGrid('getdatainformation');
    var rows = [];
    for (var i = 0; i < griddata.rowscount; i++)
    rows.push($('#jqxGrid').jqxGrid('getrenderedrowdata', i));
    console.log(JSON.parse(rows));

    You can also do the same with:

    var selected = $('#jqxGrid').jqxGrid('selectedrowindexes');

    .. and then just iterate through selected rows (“selected” will be an array).

    get all data in Grid #5173

    jonj
    Member

    Make that:

    console.log(JSON.stringify(rows));

    … for string based JSON (from object) output 🙂

    get all data in Grid #5266

    NHHL
    Member

    thanks Perter & jonj!

    I will try! 🙂

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

You must be logged in to reply to this topic.