0.1.1-rc.23 • Published 1 year ago

@wasable/react-component-datatable v0.1.1-rc.23

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Installation

Usage

Columns

PropertyTypeRequiredExample
namestringnothe display name of our Column e.g. 'Name'
sortFieldstringnoIf the column is sortable, sortField is required
cell(row) => {}yesRender your own custom component
filterobjectno(link)
operatorsOptionsarraynoAdd operators options e.g [{value: '', label: ''}]
grownumbernoflex-grow of the column

Filters

PropertyTypeRequiredExample
render(column) => {} OR stringyesRender your own custom filter OR choose one ['text', 'number, 'button]
fieldstringyesIf the column is filterable, field is required
operatorstringnoDefault operator
labelstringnoButton label
...restPropsnoIt's possible to use defaultProps of inputs e.g placeholder

Datatable

PropertyTypeRequiredDefaultExample
titlestringnoThe Title displayed in the Table Header
actionscomponentnoThe Actions displayed in the Table Header
columnsarrayyes[]The column configuration
dataarrayno[]Please, your data should have a unique identifier !
keyFieldstringno'id'Your data should have a unique identifier.
denseboolnofalseCompact the row height
stripedboolnotrueStripe color the odd rows
highlightOnHoverboolnofalseIf rows are to be highlighted on hover
pointerOnHoverboolnofalseif rows show a point icon on hover
noDataComponentcomponent OR stringnoA custom component to display when there are no records
onRowClickedfuncnoCallback to access the row, event on row click
onRowDoubleClickedfuncnoCallback to access the row, event on row double click
noHeaderboolnofalseNot displayed the Table Header
fixedHeaderboolnofalseMakes the table header fixed
fixedHeaderScrollHeightstringno50vhFixed the height value to the Table Body
showTableHeadboolnotrueDisplayed the Table Head
showTableSearchboolnotrueDisplayed the Table Search

Default Value

Row Selection

PropertyTypeRequiredDefaultExample
selectableRowsboolnofalseWhether to show selectable checkboxes
selectableRowsHighlightboolnofalseHighlight a row when it is selected
showSelectAllboolnotrueWhether to show the select all rows checkbox
selectableRowDisabled(row) => {}noDisable row select based on a property in your data. e.g. row => row.isDisabled

Replacing Components

Add property components (object) with a key present below :

  • LoadingWrapper
  • NoDataWrapper
  • Pagination
  • ResponsiveWrapper
  • Search
  • Table
  • TableBody
  • TableCell
  • TableCellCheckbox
  • TableColCheckbox
  • TableHead
  • TableHeader
  • TableHeadRow
  • TableRow
const CustomTable = ({ children, ...props }) => ( <div> <p> My New Texte </p> { children } </div> )

<DataTable components={{ Table: CustomTable }} />
0.1.1-rc.23

1 year ago