refactor: simplify row numbering calculation in DataTable component
This commit is contained in:
parent
adb89b73e7
commit
3832723921
@ -90,11 +90,7 @@ export function DataTable<TData, TValue>({
|
|||||||
const numberingColumn: ColumnDef<TData, TValue> = {
|
const numberingColumn: ColumnDef<TData, TValue> = {
|
||||||
id: "numbering",
|
id: "numbering",
|
||||||
header: "No.",
|
header: "No.",
|
||||||
cell: ({ row, table }) => {
|
cell: ({ row }) => row.index + 1,
|
||||||
const pageIndex = table.getState().pagination.pageIndex;
|
|
||||||
const pageSize = table.getState().pagination.pageSize;
|
|
||||||
return pageIndex * pageSize + row.index + 1;
|
|
||||||
},
|
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
};
|
};
|
||||||
computedColumns.unshift(numberingColumn);
|
computedColumns.unshift(numberingColumn);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user