jQWidgets Forums
Forum Replies Created
-
Author
-
June 20, 2012 at 8:30 pm in reply to: Selected items on re-sort incorrect? Selected items on re-sort incorrect? #5174
That was what I was missing. I was using the literal position-based index, not the bound index. Thank you for the clarification.
My new code:
var griddata = $('#jqxGrid').jqxGrid('getdatainformation'); // griddata.rowscount = total rows
var selected = $('#jqxGrid').jqxGrid('selectedrowindexes');
var rows = [];
for (var r = 0; r < griddata.rowscount; r++) {
var row = $('#jqxGrid').jqxGrid('getrenderedrowdata', r);
for (var s in selected)
if (row.boundindex == selected[s])
rows.push(row);
}Thank you!
Make that:
console.log(JSON.stringify(rows));
… for string based JSON (from object) output
June 20, 2012 at 3:00 am in reply to: Selected items on re-sort incorrect? Selected items on re-sort incorrect? #5131BTW, in the midst of getting your input/help, may I thank you for what a wonderful product you have created. Amazing.
June 20, 2012 at 2:58 am in reply to: Selected items on re-sort incorrect? Selected items on re-sort incorrect? #5130The scenario is that if you select multiple rows and call
var selected = $('#jqxGrid').jqxGrid('selectedrowindexes');
then the reference is correct. But if you resort, and call the same function, the “selected” array does not point to the same rows.
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).
The method ‘getdatainformation’ object worked for me (accessible parameter for rowcount therein) to get the row count and then iterate through using ‘getrenderedrowdata’ per row. Thanks.
June 19, 2012 at 1:36 am in reply to: Selected items on re-sort incorrect? Selected items on re-sort incorrect? #5076A different piece of data is selected post-sort, regardless of visual order. In other words, if I have item 1, item 2, item 3, item 4, and item 5, and select item 2, when I resort, item 3 might be selected.
Is that the intended behavior? Do I need to run an update to re-bind the select post-sort?
Well, after some head-beating, I think I have a path using this. Is there a way to get the grid “ubound” in case I wanted “all” not just “selected”?
var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
for (var i in rowindexes) {
var data = $('#jqxgrid').jqxGrid('getrenderedrowdata', rowindexes[i]);
console.log(data);
}Anyone? I really can’t believe the only way to get the current grid results, including filter/sort/edit info on all rows is by listening with bound events and trying to replicate the update(s) in the bound source?! Surely you can just enumerate/iterate the grid object rows/cols somehow?
-
AuthorPosts