Component-Specific
useDataTable
Comprehensive data table state management with sorting, filtering, and pagination.
import { useDataTable } from "saha-ui"Uses
Comprehensive table state management: sorting, filtering, column visibility, row selection and pagination. Designed to power a `DataTable` component instance.
Props
| Name | Type | Description | Default |
|---|---|---|---|
| data | array | Row data. | - |
| columns | ColumnDef[] | Column definitions including accessor and optional filter/sort functions. | - |
| enableSorting | boolean | Enable sorting. | true |
| enableFiltering | boolean | Enable filtering. | true |
| enablePagination | boolean | Enable pagination. | true |
| pageSize | number | Initial items per page. | 10 |
Returns
| Name | Description |
|---|---|
| API | API resembling a table instance: getRowModel, getHeaderGroups, getState. |
| Controls | setPageIndex, nextPage, setSorting, setColumnFilters, setColumnVisibility, setRowSelection, setGlobalFilter, etc. |
| Computed | rows, paginatedRows, page count, visibility and sorting helpers. |
Example
const table = useDataTable({ data, columns, pageSize: 20 }); const { getRowModel, nextPage } = table;Notes
Supports mixed controlled/uncontrolled patterns: provide controlled props to override internal state and use change callbacks to sync.