0.2.51 • Published 4 years ago

reactable-search v0.2.51

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

reactable-search

Searchable table with simple JSON row definitions

CircleCI Code Climate Downloads License

npm.io

live demo

Description

This React component is a simple live-searchable table with some basic enhancements:

  • Regex search
  • Optionally editable cells with callback
  • Optional separate values for display vs. sort
  • Export to CSV and JSON
  • Expandable rows

Quickstart

Install via npm

$ npm i reactable-search

Run demo

$ npm run-script demo

Usage

Basic example

import SearchTable from 'reactable-search';
import ReactDOM from 'react-dom';

const rows = [
  {a: 1, b: 2},
  {a: 2, b: 3},
  ...
];

ReactDOM.render(
  <SearchTable
    searchPrompt="Type to search"
    rows={rows}/>,
  document.getElementByID("root");

Rich cells

You may optionally specify separate values for display, search and sort for each cell. You may also provide an onChange callback function, which will cause the cell content to become editable.

Optional keydescriptiondefault
displaycontent to be rendered for displayN/A
sortValvalue to be used for sorting rows. For example, you may want to provide a formatted date string for display, but sort on the actual Date objectdisplay (innermost content if display is a DOM element)
searchTermstring value for searchingstring value of display (innermost content if display is a DOM element)
onChangefunction to receive onBlur events for editable cellsnull

Rich cell example

Note that you may use "rich" and "plain" cells in any combination

var rows = [
  {
    fruit: {
      display: <label className="label label-danger">bananas</label>,
      sortVal: 'b',
      searchTerm: 'bananas',
      onChange: (e) => { console.log('You can watch my changes:', e) }
    },
    price: 5,
    quantity: 2
  }
];

Expandable rows

Each row can be either a simple JSON object with column:cell key-value pairs, or contain separate keys for cells and children for rows that are dynamically expandable. The children key should point to a list of child rows that will be shown when the expander button is clicked. Note that child rows do not have to share the same columns as parent rows, allowing arbitary DOM to be appended to each row - see demo.

Expandable row example

const expandableRows = [
  {
    cells: {a: 1, b: 2},
    expanded: false,
    children: [
      {c: 'x'},
      ...
    ]
  }, 
  ...
];
Optional keydescriptiondefault
keyrow id provided in onRender callback (if provided) for currently displayed rowsN/A
cellssee cell definition aboveN/A
childrenList of child rows[]
expandedWhether to expand all child rows by defaultfalse
checkedcheckbox selection statusnull
selectedrow selection statusfalse
onClickclick callback fnnull
onCheckcheckbox callback fnnull
footeralways at the bottom, regardless of search or sortfalse
0.2.51

4 years ago

0.2.50

5 years ago

0.2.49

6 years ago

0.2.47

6 years ago

0.2.46

6 years ago

0.2.45

7 years ago

0.2.44

7 years ago

0.2.43

7 years ago

0.2.42

7 years ago

0.2.41

7 years ago

0.2.39

7 years ago

0.2.38

7 years ago

0.2.37

7 years ago

0.2.36

7 years ago

0.2.35

7 years ago

0.2.34

7 years ago

0.2.33

7 years ago

0.2.32

7 years ago

0.2.31

7 years ago

0.2.30

7 years ago

0.2.29

7 years ago

0.2.28

7 years ago

0.2.27

7 years ago

0.2.26

7 years ago

0.2.25

7 years ago

0.2.24

7 years ago

0.2.23

7 years ago

0.2.22

7 years ago

0.2.21

7 years ago

0.2.20

7 years ago

0.2.19

7 years ago

0.2.18

7 years ago

0.2.17

7 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.14

7 years ago

0.2.13

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago