DataTable: Live demo and source
SelectableTable: Live demo and source
npm install react-data-components --save
This component requires Bootstrap stylesheet and Font Awesome fonts, in addition
to the stylesheet for headers. If you are using Webpack
and the css-loader
you can also require the css
with require('react-data-components/css/table-twbs.css')
.
The default implementation includes a filter for case insensitive global search, pagination and page size.
var React = require('react');
var DataTable = require('react-data-components').DataTable;
var columns = [
{ title: 'Name', prop: 'name' },
{ title: 'City', prop: 'city' },
{ title: 'Address', prop: 'address' },
{ title: 'Phone', prop: 'phone' }
];
var data = [
{ name: 'name value', city: 'city value', address: 'address value', phone: 'phone value' }
// It also supports arrays
// [ 'name value', 'city value', 'address value', 'phone value' ]
];
React.render((
<DataTable
className="container"
keys={[ 'name', 'address' ]}
columns={columns}
initialData={data}
initialPageLength={5}
initialSortBy={{ prop: 'city', order: 'descending' }}
pageLengthOptions={[ 5, 20, 50 ]}
/>
), document.body);
See complete example, see Flux example.
Properties that make each row unique, e.g. an id.
See Table
column options.
The title to display on the header.
The name of the property or index on the data.
Function to render a different component.
Class name for the td.