0.1.101 • Published 2 years ago

data-table-reactjs_action-menu v0.1.101

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Forked

data table reactjs Key Features

  • Declarative Configuration
  • Built-in and configurable:
    • Sorting
    • Filtering
    • Download
    • Pagination
  • Themeable/Customizable
  • Responsive

Installation

Data table react has only react as dependancy no other third party library is used.

API and Usage

Columns

Nothing new here - we are using an array of object literals and properties to describe the columns:

PropertyTypeRequiredExample
namestringyesthe display name of our Column e.g. 'Name'
selectorstringyesa data set unique property in dot notation. e.g. property1.nested1 . A selector is required anytime you want to display data but can be ommitted if your column does not require showing data (e.g. an actions column)
sortableboolnoif the column is sortable. columns will be sorted using basic sor functions and will have ability to sort string, date, number
filterableboolnoif the column is filterable. Rows will be filter by converting data to string type
widthstringnogive the column a fixed width. Can be skiped for last column to cover remaining space.

Actions

PropertyTypeRequiredDefaultDescription
keystringyeskey to should be unique
labelstringnolabel for the action
handlerfunctionyesCall back to be called after action click which should accept index , item
classNamestringnoclass for the action

ReactDataTable Properties

Basic

PropertyTypeRequiredDefaultDescription
titlestringnoThe Title displayed in the Table Header
columnsarrayyes[]The column configuration
isLoadingboolnoShow a loader
loadingComponentComponent or stringnocustom component to display
listarrayyes[]List of records containing properties with name of column selector
actionsarrayno[]The action configuration
paginationboolnofalseto enable pagination
showSerialNumberboolnofalseto show the serial number as first column of table
showDownloadOptionboolnofalseto show download file option

Class Names to modify styles of table

the class names are self explantory and can be used to customize the table view containerClass | titleContainerClass | titleClass | downloadDropDownContainerClass | downloadDropDownClass | tableClass | tableWapperClass | headerRowClass | headerCellClass | headerIconContainerClass | filterInputContainerClass | filterInputFieldClass | filterInputCrossClass | tableBodyClassName | tableRowClass | tableCellClass | actionsClass | tableFooterClass | pageSizeDropDownContainerClass | pageSizeDropDownClass | pageNumberContainerClass | pageNumberCellClass | activePageCellClass All classes can be passed to table

Usage example

import ReactDataTable from 'data-table-reactjs';
const columns = [
  {
    name: 'column 1',
    selector: 'column1',
  },
  {
    name: 'column 2',
    selector: 'column2',
  },
];
const actions = [
  {
    key: 'viewDetails',
    handler: (index, item) => {
      console.log(index, item);
    },
    label: 'View record',
  },
];
const list = [
  {
    column1: 'Value 1',
    column2: 'value 2',
  },
  {
    column1: 'Value 3',
    column2: 'value 4',
  },
  {
    column1: 'Value 5',
    column2: 'value 6',
  },
];
const MyComponent = () => (
  <ReactDataTable
    title="Title of the table"
    columns={columns}
    list={list}
    actions={actions}
    showSerialNumber
  />
);
0.1.96

2 years ago

0.1.97

2 years ago

0.1.98

2 years ago

0.1.99

2 years ago

0.1.92

2 years ago

0.1.93

2 years ago

0.1.94

2 years ago

0.1.95

2 years ago

0.1.101

2 years ago

0.1.91

2 years ago

0.1.90

2 years ago

0.1.89

2 years ago

0.1.88

2 years ago

0.1.87

2 years ago

0.1.86

2 years ago