jQWidgets Forums
jQuery UI Widgets › Forums › Grid › get all data in Grid
Tagged: datagrid, datagridview, grid, javascript grid
This topic contains 6 replies, has 3 voices, and was last updated by NHHL 13 years ago.
-
Authorget all data in Grid Posts
-
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.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 StoevjQWidgets Team
http://www.jqwidgets.comHi 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!
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 StoevjQWidgets Team
http://www.jqwidgets.comNHHL,
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).
Make that:
console.log(JSON.stringify(rows));
… for string based JSON (from object) output
thanks Perter & jonj!
I will try!
-
AuthorPosts
You must be logged in to reply to this topic.