I am using iggrid 2012.2. I want to get the Selected Rows in the sorted order of the grid. I am using the below API to get the selected rows, But the returned rows are not in the sorted order of the grid. It is in the order in which the row selector check boxes are checked by the user
var rows = $("#grid1").igGridSelection("selectedRows");
Is there a way to get the selected rows in the sorted order as it appearing in the grid? Please help
Thanks In Advance,
Benny
Thanks for the Reply. We sorted the rows using the Sort() method of JavaScript array making use of the index property(Which will be in the sort order of the grid) of the row
rows.sort(sortRowIndexAsc);
function sortRowIndexAsc(rowA, rowB) { return rowA.index - rowB.index; }
Hello Benny,
The selectedRows method will always return the rows in the order they were selected. To get them in the order they appear in the DOM, you could either select them with a jQuery selector, or sort the array returned by selectedRows manually. For the first approach all selected rows can be obtained with the following:
$(".ui-iggrid-selectedcell").parent("tr");
Their row id-s are stored in the data-id attribute so for example you can get the first row's id with:
$(".ui-iggrid-selectedcell").parent("tr").first().attr("data-id");
I hope this helps! Thank you for using Infragistics forums!
Best regards,
Stamen Stoychev