Skip to content

Commit 93caf3d

Browse files
authored
Allow specifying column order in DataTable (#6501)
1 parent 8d32fa3 commit 93caf3d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

frontend/app/src/shared/components/table/data-table.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ import {
55
ObjectTableToolbar,
66
} from "@/entities/nodes/object/ui/object-table/toolbar/object-table-toolbar";
77
import { NodeObject } from "@/entities/nodes/types";
8-
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
8+
import {
9+
ColumnDef,
10+
ColumnOrderState,
11+
flexRender,
12+
getCoreRowModel,
13+
useReactTable,
14+
} from "@tanstack/react-table";
915
import React from "react";
1016

1117
export interface DataTableProps<T> extends React.HTMLAttributes<HTMLDivElement> {
18+
columnOrder?: ColumnOrderState;
1219
columns: ColumnDef<T>[];
1320
data: Array<T>;
1421
isLoading?: boolean;
@@ -17,6 +24,7 @@ export interface DataTableProps<T> extends React.HTMLAttributes<HTMLDivElement>
1724
}
1825

1926
export function DataTable<T extends NodeObject>({
27+
columnOrder,
2028
columns,
2129
data,
2230
isLoading,
@@ -32,6 +40,9 @@ export function DataTable<T extends NodeObject>({
3240
getCoreRowModel: getCoreRowModel(),
3341
manualSorting: true,
3442
getRowId: (row) => row.id,
43+
state: {
44+
columnOrder,
45+
},
3546
});
3647

3748
React.useEffect(() => {

0 commit comments

Comments
 (0)