diff --git a/packages/apsara-ui/src/TableV2/Table.stories.tsx b/packages/apsara-ui/src/TableV2/Table.stories.tsx index cd6d2e7d..d1285ded 100644 --- a/packages/apsara-ui/src/TableV2/Table.stories.tsx +++ b/packages/apsara-ui/src/TableV2/Table.stories.tsx @@ -84,6 +84,7 @@ const columns = [ title: "Age", dataIndex: "age", key: "age", + width: 20, }, { title: "Address", diff --git a/packages/apsara-ui/src/TableV2/Table.tsx b/packages/apsara-ui/src/TableV2/Table.tsx index 48385d8a..c3c09f94 100644 --- a/packages/apsara-ui/src/TableV2/Table.tsx +++ b/packages/apsara-ui/src/TableV2/Table.tsx @@ -60,6 +60,7 @@ function Table({ columnHelper.accessor(item.key, { cell: item.render ? item.render : (info) => info.getValue(), header: item.title ?? item.dataIndex, + size: item.width, }), ); }); @@ -145,14 +146,21 @@ function Table({ }; return ( - + {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( - (rowClick ? rowClick(row) : "")}> {row.getVisibleCells().map((cell) => ( - ))} diff --git a/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx b/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx index 106e72bb..9ac7e3a9 100644 --- a/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx +++ b/packages/apsara-ui/src/TableV2/VirtualisedTable.tsx @@ -74,6 +74,7 @@ function VirtualisedTable({ columnHelper.accessor(item.key, { cell: item.render ? item.render : (info) => info.getValue(), header: item.title ?? item.dataIndex, + size: item.size, }), ); }); @@ -117,7 +118,11 @@ function VirtualisedTable({ {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( - );
+ {header.isPlaceholder ? null : (
(
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ {header.isPlaceholder ? null : (
(rowClick ? rowClick(row) : "")}> {row.getVisibleCells().map((cell) => { return ( -
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}