Skip to main content

Overview

import CustomDataTable from "@components/custom-data-table/CustomDataTable"

Description

this component allows to show an array in a data table view
it uses DataTable of Tag Component and supports filtering and displays the data count

Usage example

Code

import CustomDataTable from "@components/custom-data-table/CustomDataTable";

function Demo() {
const data = [
{
name: "Bob",
lastActive: "2018-07-18T10:09:30.662Z",
score: 10.5,
},
{
name: "Jane",
lastActive: "2018-07-13T10:09:30.662Z",
score: 12,
},
{
name: "Fred",
lastActive: "2018-07-19T10:09:00.662Z",
score: 9.5,
},
];
const columns = [
{ accessorKey: "name", header: "Name" },
{
accessorKey: "lastActive",
header: "Last Active",
meta: { dataType: "date" },
},
{ accessorKey: "score", header: "Score", meta: { dataType: "decimal" } },
];
const options = {
data: data,
columns: columns,
};
return <CustomDataTable options={options}></CustomDataTable>;
}

Result

NameLast ActiveScore
Bob18/07/201810.5
Jane13/07/201812
Fred19/07/20189.5

Props

NameTypeDescription
dataArrayThe data that drives the table content
urlstringThe url used to get remote data
columnsArray<Column>(see column props below )The column definitions
initialDataStateDataStatethe state to be applied on data
pageablebooleanenable/disable pagination
filterablebooleanenable/disable filtering for all columns
sortablebooleanenable/disable column sorting
stickyleft,rightif left then first column will be sticky else the last column will be sticky
tablePropsObjectcontains DataTable Props (see DataTable Tag Props)

Column Props

All the column options from DataTable Tag are available, in addition to the following:

NameTypeDescription
filterablebooleanenable/disable column filtering
customColumnFilterCustomColumnFilterused to display column filter based on list options