99.1.8 • Published 8 years ago

@sstur/react-data-components v99.1.8

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

react-data-components

DataTable: Live demo and source.

Getting started

npm install react-data-components --save

Using the default implementation

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: 'desc' }}
      pageLengthOptions={[ 5, 20, 50 ]}
    />
  ), document.body);

See complete example, see Flux example.

DataMixin options

NameTypeDescription
keysarrayProperties that make each row unique, e.g. an id.
columnsarraySee column options.
pageLengthOptionsarrayPage length options.
initialDataarrayThe data to display.
initialPageLengthnumberInitial page length.
initialSortByobjectInitial sorting, needs prop and order.

Table column options

NameTypeDescription
titlestringThe title to display on the header.
propstring or numberThe name of the property or index on the data.
renderfunctionFunction to customize the render on column.
classNamestring or functionClass for the td.
defaultContentstringThe default value to display if no data.
sortablebooleantrue by default.
widthstring or numberWidth for the column.