Data Table
Powerful table compatible with SSR, search, pagination and more.
Data Table is a powerful table component build with scratch for VitNode. It's compatible with SSR, search, pagination and even in query state from the URL.
Preview
ID | Name |
---|---|
1 | John Doe |
2 | Jane Doe 2 |
Usage
Examples
With Pagination
Backend
You can read how to implement Pagination API here.
With Search
With Custom Cell
Actions
We created special column for actions. You can add buttons, links or any other components. Flex is used for the layout with gap.
With Sorting Column
Backend
You can read how to implement Sorting API here.
API Reference
Prop | Type | Default |
---|---|---|
data | { id: number; and others... }[] | - |
columns | { id: string; title: string; sortable?: boolean; cell?: ({ row: Data; data: Data[] }) => ReactNode; }[] | - |
defaultSorting | { sortBy: string; sortDirection: "asc" | "desc"; } | - |
searchPlaceholder | string | - |
pageInfo | PageInfo from GraphQL | - |
defaultPageSize | 10 | 20 | 30 | 40 | 50 | 10 |
Usage with Pagination API
Backend API
You can read how to implement Pagination API here.
Get data from API
Create getData
function and privide in it the fetcher
function.
Create the view
Create the view function with searchParams
argument.
Get data with getPaginationTool
Use the getPaginationTool
function to get the data and pagination information.
The getPaginationTool()
function will automatically handle the pagination, search and sorting for you when you're using the DataTable
component.
Usage with Sorting API
Backend API
You can read how to implement Sorting API here.
Pagination Required
Sorting system is based on Pagination. Please make sure you have implemented the pagination system before using the sorting system.