Skip to main content

DataTable

DataTable

A data table which includes sorting, filtering, pagination, bulk actions, column controls etc.

This is the building block of all data tables in the Dashboard.

Signature
function DataTable<TData>(props: Readonly<DataTableProps<TData>>): void

Parameters

props

parameter
Readonly<DataTableProps<TData>>

DataTableProps

Props for configuring the DataTable.

Signature
interface DataTableProps<TData> {
children?: React.ReactNode;
columns: ColumnDef<TData, any>[];
data: TData[];
totalItems: number;
isLoading?: boolean;
page?: number;
itemsPerPage?: number;
sorting?: SortingState;
columnFilters?: ColumnFiltersState;
onPageChange?: (table: TableType<TData>, page: number, itemsPerPage: number) => void;
onSortChange?: (table: TableType<TData>, sorting: SortingState) => void;
onFilterChange?: (table: TableType<TData>, columnFilters: ColumnFilter[]) => void;
onColumnVisibilityChange?: (table: TableType<TData>, columnVisibility: VisibilityState) => void;
onSearchTermChange?: (searchTerm: string) => void;
defaultColumnVisibility?: VisibilityState;
facetedFilters?: { [key: string]: FacetedFilter | undefined };
disableViewOptions?: boolean;
bulkActions?: BulkAction[];
setTableOptions?: (table: TableOptions<TData>) => TableOptions<TData>;
onRefresh?: () => void;
}

children

property
React.ReactNode

columns

property
ColumnDef<TData, any>[]

data

property
TData[]

totalItems

property
number

isLoading

property
boolean

page

property
number

itemsPerPage

property
number

sorting

property
SortingState

columnFilters

property
ColumnFiltersState

onPageChange

property
(table: TableType<TData>, page: number, itemsPerPage: number) => void

onSortChange

property
(table: TableType<TData>, sorting: SortingState) => void

onFilterChange

property
(table: TableType<TData>, columnFilters: ColumnFilter[]) => void

onColumnVisibilityChange

property
(table: TableType<TData>, columnVisibility: VisibilityState) => void

onSearchTermChange

property
(searchTerm: string) => void

defaultColumnVisibility

property
VisibilityState

facetedFilters

property
{ [key: string]: FacetedFilter | undefined }

disableViewOptions

property
boolean

bulkActions

property

setTableOptions

property
(table: TableOptions<TData>) => TableOptions<TData>

This property allows full control over all features of TanStack Table when needed.

onRefresh

property
() => void

DashboardDataTableDisplayComponent

Allows you to define custom display components for specific columns in data tables. The pageId is already defined in the data table extension, so only the column name is needed.

Signature
interface DashboardDataTableDisplayComponent {
column: string;
component: React.ComponentType<{ value: any; [key: string]: any }>;
}

column

property
string

The name of the column where this display component should be used.

component

property
React.ComponentType<{ value: any; [key: string]: any }>

The React component that will be rendered as the display. It should accept value and other standard display props.

BulkAction

Status: Developer Preview

A bulk action is a component that will be rendered in the bulk actions dropdown.

Signature
type BulkAction = {
order?: number;
component: BulkActionComponent<any>;
}

order

property
number

Optional order number to control the position of this bulk action in the dropdown. A larger number will appear lower in the list.

component

property
BulkActionComponent<any>

The React component that will be rendered as the bulk action item.

DashboardDataTableExtensionDefinition

This allows you to customize aspects of existing data tables in the dashboard.

Signature
interface DashboardDataTableExtensionDefinition {
pageId: string;
blockId?: string;
bulkActions?: BulkAction[];
extendListDocument?: string | DocumentNode | (() => DocumentNode | string);
displayComponents?: DashboardDataTableDisplayComponent[];
}

pageId

property
string

The ID of the page where the data table is located, e.g. 'product-list', 'order-list'.

blockId

property
string

The ID of the data table block. Defaults to 'list-table', which is the default blockId for the standard list pages. However, some other pages may use a different blockId, such as 'product-variants-table' on the 'product-detail' page.

bulkActions

property

An array of additional bulk actions that will be available on the data table.

extendListDocument

property
string | DocumentNode | (() => DocumentNode | string)

Allows you to extend the list document for the data table.

displayComponents

Custom display components for specific columns in the data table.