I'm using this method igGridSelection('selectedRows') to get the selected rows, but it does not return all the selected rows when using the grid's paging feature. It looks like it only returns the selectedRows for the current page. I'm using the EnableCheckBoxes feature to display a checkbox on the row, and I would like to get all the rows with the checkbox checked on all the pages.
Thanks
Hello,
One possible approach is using a global variable which keeps an array of the currently selected records. When new records are added to the selection the rowSelectionChanged event is handled and the array is updated with them:
$("#grid1").igGrid({
features: [
{
name: "Selection",
mode: "row",
rowSelectionChanged: function (evt, ui) {
selectedRowsKeeper.push(ui.row);
…
}
]
});
It is also needed the pageIndexChanged event to be handled in order the rows from previous pages to be reselected again:
$(".selector").igGrid({
features: [{
name: "Paging",
pageIndexChanged: function (evt, ui) {
var l = selectedRowsKeeper.length;
for (var i = 0; i < l; i++)
$(this).igGridSelection(“selectRow”, selectedRowKeeper[i].index);
}]
If you need any further assistance please let me know.
Can you please share the sample code ? I'm having a hard time implementing this functionality.
A developer here wanted to do the same thing and I believe the answer was that you needed to manage that on your own. Most of the API's only work with the current page or result set. What you need to do is hook into the page change 'ing' event and capture which items are selected before the page changes.
Then when you want work that subset of data, you'll need to base it off of the what you have locally. He was able to achieve the same effect without much effort.