Posted 27 August 2021, 3:21 am EST
I had an idea to complete both, below link help me to complete the pagination part. It works well.
https://www.grapecity.com/forums/wijmo/ask-for-server-side-pagina#hiif-your-server-does-not-
And I am writing the Select All function. sourceCollection changes every time turn page, and recheck select items after source collection is changed. But the sourceCollectionChanges can’t be triggered after load page data. Why?
initGrid(grid) {
this.gridSG = grid;
this.gridSelector = new Selector(grid, {
itemChecked: () => {
}
});
this.selectRows(grid);
}
selectRows(grid) {
let self = this;
grid.hostElement.addEventListener('click', e => {
let hti = grid.hitTest(e);
if (hti.cellType == wjGrid.CellType.ColumnHeader && hti.col == 0) {
for (let i = 0; i < grid.collectionView.sourceCollection.length; i++) {
if (e.target.checked) {
//grid.collectionView.sourceCollection[i].sel = true;
self.selectedItems = self.allSiblingGroups;
} else {
//grid.collectionView.sourceCollection[i].sel = false;
self.selectedItems = [];
}
}
} else if (hti.cellType == wjGrid.CellType.Cell && hti.col == 0) {
let currentItem = self.pagData.currentItem;
let currentRow = grid.rows.filter(r => r.dataItem.id == currentItem.id)[0];
//self.pagData.currentItem.sel = currentRow.isSelected;
if (currentRow.isSelected) {
this.selectedItems.push(currentRow.dataItem);
}
else {
this.selectedItems = this.selectedItems.filter(r => r.dataItem.id != currentItem.id);
}
}
});
grid.collectionView.collectionChanged.addHandler(()=>{
self.sourceCollectionChanged();
});
}
sourceCollectionChanged() {
for (let i = 0; i < this.gridSG.rows.length; i++) {
let itemData = this.gridSG.collectionView.items[i].dataItem;
if (this.selectedItems.indexOf(itemData) > -1) {
this.gridSG.rows[i].isSelected = true;
}
else {
this.gridSG.rows[i].isSelected = false;
}
}
}