Components

DataTable

<DataTable data columns tableId sortId itemsPerPageOptions itemsPerPageSelectionEnabled searchEnabled sortSelectionEnabled tableInfoEnabled paginationEnabled dataTablesWrapperClassName dataTablesLengthClassName dataTablesLengthLabelClassName dataTablesLengthSelectClassName dataTablesLengthOptionClassName dataTablesSearchWrapperClassName dataTablesSearchLabelClassName dataTablesSearchInputClassName dataTablesInfoClassName dataTablesPaginateClassName dataTableClassName dataTableHeaderClassName dataTableHeaderTrClassName dataTableHeaderThClassName dataTableHeaderSortedClassName dataTableBodyClassName dataTableBodyTrClassName dataTableBodyTdClassName dataTableBodyTdSortedClassName dataTableBodyTdEmptyClassName dataTableBodyOddRowClassName dataTableBodyEvenRowClassName />

Constructor

# <DataTable data columns tableId sortId itemsPerPageOptions itemsPerPageSelectionEnabled searchEnabled sortSelectionEnabled tableInfoEnabled paginationEnabled dataTablesWrapperClassName dataTablesLengthClassName dataTablesLengthLabelClassName dataTablesLengthSelectClassName dataTablesLengthOptionClassName dataTablesSearchWrapperClassName dataTablesSearchLabelClassName dataTablesSearchInputClassName dataTablesInfoClassName dataTablesPaginateClassName dataTableClassName dataTableHeaderClassName dataTableHeaderTrClassName dataTableHeaderThClassName dataTableHeaderSortedClassName dataTableBodyClassName dataTableBodyTrClassName dataTableBodyTdClassName dataTableBodyTdSortedClassName dataTableBodyTdEmptyClassName dataTableBodyOddRowClassName dataTableBodyEvenRowClassName />

Takes in data, columns and returns a table that can be sorted (if the column is declared sortable), filtered (can be disable), and paginated (can be disable). data and columns must be arrays of object.

data must be an array of objects, each object will be a row in the table, the keys in the objects must be the id of the column. [{ idOfColumnOne: "dataOfColumnOne", idOfColumnTwo: "dataOfColumnTwo", idOfColumnThree: "dataOfColumnThree", ...},...]

columns must be an array of objects with the following properties: [{ name: "First Name", id: "firstName", sortable: true, headColSpan: 2, bodyColSpan: 2 },...] name: the name of the column displayed in the table header. id: the id of the column sortable: boolean, if the column is sortable headColSpan: size of the column in the header bodyColSpan: size of the column in the body

PropTypes:
Name Type Required Description Default
data arrayOf Yes The data to be displayed in the table
columns arrayOf Yes The columns to be displayed in the table
tableId string Yes The id of the table
sortId string No The id of the column to be sorted function()
itemsPerPageOptions array No The options for the items per page dropdown [10, 25, 50, 100]
itemsPerPageSelectionEnabled bool No Whether the items per page dropdown should be enabled true
searchEnabled bool No Whether the search input should be enabled true
sortSelectionEnabled bool No Whether the sort dropdown should be enabled true
tableInfoEnabled bool No Whether the table info should be enabled true
paginationEnabled bool No Whether the pagination should be enabled true
dataTablesWrapperClassName string No The class name of the wrapper div "data-tables-wrapper"
dataTablesLengthClassName string No The class name of the length div "data-tables-length"
dataTablesLengthLabelClassName string No The class name of the length label "data-tables-length-label"
dataTablesLengthSelectClassName string No The class name of the length select "data-tables-length-select"
dataTablesLengthOptionClassName string No The class name of the length options "data-tables-length-option"
dataTablesSearchWrapperClassName string No The class name of the search wrapper div "data-tables-search-wrapper"
dataTablesSearchLabelClassName string No The class name of the search label "form-label"
dataTablesSearchInputClassName string No The class name of the search input "form-input"
dataTablesInfoClassName string No The class name of the info div "data-tables-info"
dataTablesPaginateClassName string No The class name of the paginate div "data-tables-paginate"
dataTableClassName string No The class name of the table "data-table"
dataTableHeaderClassName string No The class name of the table header "data-table-header"
dataTableHeaderTrClassName string No The class name of the table header tr "data-table-header-tr"
dataTableHeaderThClassName string No The class name of the table header th "data-table-header-th"
dataTableHeaderSortedClassName string No The class name of the table header th sorted "sorting"
dataTableBodyClassName string No The class name of the table body "data-table-body"
dataTableBodyTrClassName string No The class name of the table body tr "data-table-body-tr"
dataTableBodyTdClassName string No The class name of the table body td "data-table-body-td"
dataTableBodyTdSortedClassName string No The class name of the table body td sorted "sorting_1"
dataTableBodyTdEmptyClassName string No The class name of the table body td empty "data-tables-empty"
dataTableBodyOddRowClassName string No The class name of the table body tr odd "odd"
dataTableBodyEvenRowClassName string No The class name of the table body tr even "even"

View Source DataTable/index.jsx, line 32

  • The table component.
React.Component

Methods

# inner handleChangeItemsPerPage()

Sets the items per page to the value of the event target and sets the current page to 1.

View Source DataTable/index.jsx, line 197

# inner handleSearch()

Takes the search input and filters the data based on the search input

View Source DataTable/index.jsx, line 159

# inner handleSortChange()

If the column is the same as the current sort column, then toggle the sort order. Otherwise, set the sort order to ascending

View Source DataTable/index.jsx, line 181

# inner sortData()

It sorts the data by date if the value is a valid date, otherwise it sorts the data by string

View Source DataTable/index.jsx, line 71

the sorted data.