Skip to content

Commit 1a6ba03

Browse files
Remove row number column from grid (#20501)
1 parent 11a3591 commit 1a6ba03

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

src/reactviews/pages/TableExplorer/TableDataGrid.tsx

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,6 @@ export const TableDataGrid = forwardRef<TableDataGridRef, TableDataGridProps>(
158158

159159
// Create columns from columnInfo
160160
function createColumns(columnInfo: any[]): Column[] {
161-
// Row number column
162-
const rowNumberColumn: Column = {
163-
id: "rowNumber",
164-
name: '<span class="table-row-number">#</span>',
165-
field: "id",
166-
excludeFromColumnPicker: true,
167-
excludeFromGridMenu: true,
168-
excludeFromHeaderMenu: true,
169-
width: 50,
170-
minWidth: 40,
171-
maxWidth: 80,
172-
sortable: false,
173-
resizable: true,
174-
focusable: false,
175-
selectable: false,
176-
formatter: (row: number) => {
177-
const paginationService = reactGridRef.current?.paginationService;
178-
const pageNumber = paginationService?.pageNumber ?? 1;
179-
const itemsPerPage = paginationService?.itemsPerPage ?? pageSize;
180-
const actualRowNumber = (pageNumber - 1) * itemsPerPage + row + 1;
181-
return `<span class="table-row-number">${actualRowNumber}</span>`;
182-
},
183-
};
184-
185161
// Data columns
186162
const dataColumns: Column[] = columnInfo.map((colInfo, index) => {
187163
const column: Column = {
@@ -198,7 +174,7 @@ export const TableDataGrid = forwardRef<TableDataGridRef, TableDataGridProps>(
198174
dataContext: any,
199175
) => {
200176
const rowId = dataContext.id;
201-
const changeKey = `${rowId}-${cell - 1}`;
177+
const changeKey = `${rowId}-${cell}`;
202178
const isModified = cellChangesRef.current.has(changeKey);
203179
const hasFailed = failedCellsRef.current.has(changeKey);
204180
const displayValue = value ?? "";
@@ -254,7 +230,7 @@ export const TableDataGrid = forwardRef<TableDataGridRef, TableDataGridProps>(
254230
return column;
255231
});
256232

257-
return [rowNumberColumn, ...dataColumns];
233+
return dataColumns;
258234
}
259235

260236
// Handle page size changes from props
@@ -452,7 +428,7 @@ export const TableDataGrid = forwardRef<TableDataGridRef, TableDataGridProps>(
452428
}
453429

454430
const cellIndex = args.cell;
455-
const columnIndex = cellIndex - 1;
431+
const columnIndex = cellIndex;
456432
const column = columns[cellIndex];
457433
const rowId = args.item.id;
458434

@@ -530,7 +506,7 @@ export const TableDataGrid = forwardRef<TableDataGridRef, TableDataGridProps>(
530506

531507
case "revert-cell":
532508
const cellIndex = args.cell;
533-
const columnIndex = cellIndex - 1;
509+
const columnIndex = cellIndex;
534510
const changeKey = `${rowId}-${columnIndex}`;
535511

536512
if (onRevertCell) {

0 commit comments

Comments
 (0)