Posted 30 July 2021, 1:36 pm EST
Yes. It is also happening with the stakcblitz you attached, below is the code being called from the gird’s itemformatter
/**
* @description
* Formats each cell upon update events. Called by flexgrid... all the time.
* Notably this function adds checkboxes to the first column rows and header
*
* @param panel - flexgrid panel
* @param r - row index
* @param c - column index
* @param cell - current flexgrid cell
*/
public itemFormatter(panel: GridPanel, r: number, c: number, cell: any) {
// add checkbox to header, sync with checkboxes in column
if (panel.cellType === CellType.ColumnHeader) {
const flex = panel.grid;
const col = flex.columns[c];
// check that this is a boolean column
if (col.dataType === DataType.Boolean && c === 0 && r === 0) {
// prevent sorting on click
col.allowSorting = false;
for (let i = 0; i < flex.rows.length; i++) {
const intialCheck = flex.getCellData(i, c, false);
if (typeof intialCheck === 'undefined') {
flex.setCellData(i, c, false);
}
}
// count true values to initialize checkbox
let cnt = 0;
for (let i = 0; i < flex.rows.length; i++) {
if (flex.getCellData(i, c, false) === true) {
cnt++;
}
}
// create and initialize checkbox
cell.innerHTML = '<input type="checkbox" style="height: 13px !important;">';
const cb = cell.firstChild;
cb.checked = cnt > 0;
cb.indeterminate = cnt > 0 && cnt < flex.rows.length;
// apply checkbox value to cells
cb.addEventListener('click', () => {
flex.beginUpdate();
for (let i = 0; i < flex.rows.length; i++) {
flex.setCellData(i, c, cb.checked);
}
flex.endUpdate();
const update = this.updateInvoiceData.bind(this);
update();
});
}
}
}