-
Strugglig to find a way to set the column alignment in v8, is there an align property somehwere or a way to add metadata to columns? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
ok appears a column has a meta propery typed as unknown. So can put an align in there then cast it when making the td
|
Beta Was this translation helpful? Give feedback.
-
@bzbetty can someone set label to V8 for this discussion? didn't see this discussion on v8 label, so opens up new one #4439 |
Beta Was this translation helpful? Give feedback.
-
None of these things have been working for me on |
Beta Was this translation helpful? Give feedback.
-
Just a note to get this to work with import '@tanstack/react-table';
declare module '@tanstack/react-table' {
interface ColumnMeta<TData extends RowData, TValue> {
align?: 'left' | 'right';
}
} Docs: https://tanstack.com/table/v8/docs/api/core/column-def#meta |
Beta Was this translation helpful? Give feedback.
-
This works for me, hope it helps. {
accessorKey: "isDelivered",
header: () => <div className="text-center">Delivered</div>,
cell: ({ row }) => {
const value: string = row.getValue("isDelivered");
if (value === "No") {
return (
<div className="text-center">
<Badge variant="destructive">{value}</Badge>
</div>
);
}
return <Badge variant="outline">{value}</Badge>;
},
}, Change the cell alignment with a enclosed div <div className="text-center">
{row.getValue("yourValue")}
</div> Change the header alignment to your choosing. header: () => <div className="text-center">Delivered</div>, |
Beta Was this translation helpful? Give feedback.
ok appears a column has a meta propery typed as unknown.
So can put an align in there then cast it when making the td
<td key={cell.id} align={(cell.column.columnDef.meta as any)?.align}>