Added table sorting. next up: filtering

This commit is contained in:
2026-02-20 00:17:16 +05:30
parent ab785c610f
commit fe3d9ac852
2 changed files with 39 additions and 3 deletions

View File

@@ -1,11 +1,15 @@
"use client";
import { useState } from "react";
import {
ColumnDef,
flexRender,
getCoreRowModel,
getPaginationRowModel,
useReactTable,
SortingState,
getSortedRowModel,
} from "@tanstack/react-table";
import {
@@ -35,11 +39,18 @@ export function DataTable<TData, TValue>({
columns,
data,
}: DataTableProps<TData, TValue>) {
const [sorting, setSorting] = useState<SortingState>([]);
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(),
state: {
sorting,
},
});
return (