表格增加序号列,移除 id 列
This commit is contained in:
@@ -29,6 +29,7 @@ export type DataTableProps<T> = {
|
||||
headRow?: string
|
||||
dataRow?: string
|
||||
}
|
||||
serial?: boolean
|
||||
}
|
||||
|
||||
export function DataTable<T extends Record<string, unknown>>(
|
||||
@@ -36,7 +37,14 @@ export function DataTable<T extends Record<string, unknown>>(
|
||||
) {
|
||||
const table = useReactTable({
|
||||
data: props.data,
|
||||
columns: props.columns,
|
||||
columns: [
|
||||
{
|
||||
id: "serial",
|
||||
header: "#",
|
||||
cell: ({ row }) => row.index + 1,
|
||||
},
|
||||
...props.columns,
|
||||
],
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
manualPagination: true,
|
||||
rowCount: props.pagination?.total,
|
||||
|
||||
Reference in New Issue
Block a user