var pages = [];
var pageCountRange = [];
// Grid’s load event handler
function onGridLoad() {
// Retrieves Grid’s current page size
var pageSize = grid.pageSettings.pageSize;
var i = 0;
// Page indexes are stored in global variable for performing the selection operation
while (i < pageSize) {
pageCountRange.push(i);
i++;
}
}
// Grid’s headerCellInfo event handler
function gridHeaderCellInfo(args) {
// Click action is defined for the check all checkbox
var checkEle = args.node.querySelector(".e-checkbox-wrapper");
if (checkEle) {
checkEle.addEventListener("click", onCheckClick.bind(this));
}
}
// Check all click event function
function onCheckClick(args) {
var pageIndex = grid.pageSettings.currentPage;
// Store/remove the current page value in a global array based on check state
if (args.target.classList.contains("e-check")) {
var pageIndex = pages.indexOf(pageIndex);
pages.splice(pageIndex, 1);
} else {
pages.push(pageIndex);
}
}
// Grid’s actionComplete event handler
function onGridActionComplete(args) {
// Check if the action performed is ‘paging’ and if the current page has been stored in global variable
if (args.requestType === "paging" && pages.indexOf((args as PageSettingsModel).currentPage) !== -1) {
// the current page rows are selected
grid.selectRows(pageCountRange);
}
} |
let selectedRows = mainGrid.getSelectedRecords();
let currentView = mainGrid.getCurrentViewRecords();