Posted 4 February 2026, 8:51 am EST
Hi Mary,
This seems like a typescript error; you can set the ‘row’ type to any to resolve this issue. Please refer to the following updated code -
loadedRows: (s, e) => {
let idx = s.rowHeaders.columns.findIndex(c => c.binding == 'counterCol');
if (idx == -1) {
s.rowHeaders.columns.push(new wjGrid.Column({ binding: 'counterCol', header: 'Row Count', width: 90, align: 'center' }))
}
// to assign a row number to each row
let rowCounter = 0;
// for typescript
s.rows.forEach((row: any) => {
if (!row.rowCounter) {
let internalData = JSON.stringify(row._ubv).toLowerCase();
// use this if you want to remove row number from subtotal rows as well
// if (internalData.indexOf('subtotal') == -1 && internalData.indexOf('grand total') == -1) {
if (internalData.indexOf('grand total') == -1) {
row.rowCounter = ++rowCounter;
}
}
})
},
// to add row numbers
formatItem: (s, e) => {
if (e.panel == s.rowHeaders) {
let col = e.getColumn();
let row = s.rows[e.row] as any;
if (col.binding == 'counterCol') {
e.cell.textContent = row.rowCounter;
}
}
}
You can also use the following code in the previous sample we shared, if you only want to remove the row number from the grand total row, which is always the last row in the grid -
formatItem: (s, e) => {
if (e.panel == s.rowHeaders) {
let col = e.getColumn();
if (col.binding == 'counterCol' && e.row != s.rows.length-1) {
e.cell.textContent = e.row + 1;
}
}
}
Regards