2.8.2 • Published 7 years ago

tablo v2.8.2

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

Tablo

npm package

Tablo is a React table component. Check it on this playground here.

It has the following features

  • filtering or searching by column
  • sorting by column
  • paging
  • injecting any components into cells (for making edit buttons, selections etc.)

Installation

Tablo is available as an npm package.

npm install tablo

Styling

You must reference the style.css stylesheet that comes in the tablo directory in some way.
You can change this file to suit your styling needs, or create your own style under the class name tablo.

Usage

The following is one of the simplest examples you can have

import React from 'react';
import Tablo from 'tablo';

const users = [
  { code: 0, name: "Ivana Burnett", country: "Uzbekistan" }, 
  { code: 1, name: "Iliana Spence", country: "San Marino" }
];

const columns = [
  { key: "name", name: "Name" },
  { key: "country", name: "Country" }
];

const Example = () => (
  <Tablo
     items={users}
     limit={10}
     columns={columns}
     id="code"
  />
);

Table properties

Parameter NameDescription
itemsan array of objects that acts as the rows of the table
columnsan array of objects that specify the columns of the table, and how the rows must be displayed
limit(optional: defaults to 15) the number of entries you want to have displayed per page
keythe key that is unique for each item in items array
exportName(optional) only specify this if you want the table to be exportable. This will then be used as the file name
sort(optional) specifies the sorted column at render : an object of { key, asc } where key corresponds to the sorted column, and asc whether or not it is ascending

Column properties

The following properties can be added to the columns property of the table

Parameter NameDescription
keythe key that correspons to the value you want to display of each item in this column. Note that the values in the rows may only be strings or numbers
namethe display name of the column
searchable(optional) if the column is searchable
filterable(optional) if the column is filterable
header(optional) this is a react component to replace the display name of the column, as in: const simpleComponent = <div>A complex<em>header</em></div>
sortable(optional) if the column is sortable
widthspecify the fixed width of a column
componenta function that takes the corresponding item as the paramater. A valid react component must be returned. A simple example of such a function is: const simpleFunction = item => <div>{item.prop1}</div>;

Notes

  • You can only specify at most one of: filterable, searchable, or header
  • When you specify a key, and it references a value that is some layers deep, you may do so with the dot (.) seperator. Say item = { a: { b: { c: 61 } } } , then the "a.b.c" key of item will return 61;
  • The only property passed to Tablo that may change is items. Any other property won't be used or displayed. If you do wish to use new properties, remount the Tablo component.
2.8.2

7 years ago

2.8.1

7 years ago

2.8.0

7 years ago

2.7.9

7 years ago

2.7.8

7 years ago

2.7.7

8 years ago

2.7.6

8 years ago

2.7.5

8 years ago

2.7.3

8 years ago

2.7.2

8 years ago

2.7.1

8 years ago

2.7.0

8 years ago

2.6.0

8 years ago

2.5.3

8 years ago

2.5.2

8 years ago

2.5.1

8 years ago

2.5.0

8 years ago

2.4.5

8 years ago

2.4.4

8 years ago

2.4.3

8 years ago

2.4.2

8 years ago

2.4.1

8 years ago

2.4.0

8 years ago

2.3.8

8 years ago

2.3.7

8 years ago

2.3.6

8 years ago

2.3.5

8 years ago

2.3.4

8 years ago

2.3.3

8 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.10

8 years ago

2.2.9

8 years ago

2.2.8

8 years ago

2.2.7

8 years ago

2.2.6

8 years ago

2.2.5

8 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.2

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.0

8 years ago

0.1.0

8 years ago

0.0.0

8 years ago

1.0.0

8 years ago