In the UI-grid, there is a "select All" checkbox that, when checked, selects all the records visible on the current page and other pages.
Query - Is there a way to select rows displayed only on the current page?
You can check out the example on plunker: http://plnkr.co/edit/gHiER0A2Oaia4HMWChcG?p=preview
I have tried using the API
$scope.gridApi.selection.selectAllVisibleRows();
but it seems to select rows across all pages. Even if you click on "Select Visible Rows" and move to the next page, the records there are also selected.
Additional information about the API selectAllVisibleRows
Upon checking inside the ui-grid function selectAllVisibleRows, the row.visible
returns true
for all the rows across all pages
.
selectAllVisibleRows: function (evt) {
if (grid.options.multiSelect === false) {
return;
}
var changedRows = [];
grid.rows.forEach(function (row) {
if (row.visible) {
if (!row.isSelected && row.enableSelection !== false){
row.setSelected(true);
service.decideRaiseSelectionEvent( grid, row, changedRows, evt );
}
} else {
if (row.isSelected){
row.setSelected(false);
service.decideRaiseSelectionEvent( grid, row, changedRows, evt );
}
}});
service.decideRaiseSelectionBatchEvent( grid, changedRows, evt );
grid.selection.selectAll = true;
},