/* eslint-disable import/no-webpack-loader-syntax */ import React from 'react' import _ from 'lodash' import namor from 'namor' import ReactTable from '../../../lib/index' class Story extends React.PureComponent { constructor (props) { super(props) const data = _.map(_.range(5553), d => { return { firstName: namor.generate({words: 1, numbers: 0}), lastName: namor.generate({words: 1, numbers: 0}), age: Math.floor(Math.random() * 30) } }) this.state = { tableOptions: { loading: false, showPagination: true, showPageSizeOptions: true, showPageJump: true, collapseOnSortingChange: true, collapseOnPageChange: true, collapseOnDataChange: true, freezeWhenExpanded: false, filterable: false, sortable: true, resizable: true }, data: data } this.setTableOption = this.setTableOption.bind(this) } render () { const columns = [{ Header: 'Name', columns: [{ Header: 'First Name', accessor: 'firstName' }, { Header: 'Last Name', id: 'lastName', accessor: d => d.lastName }] }, { Header: 'Info', columns: [{ Header: 'Age', accessor: 'age' }] }] return (

Table Options

{ Object.keys(this.state.tableOptions).map(optionKey => { const optionValue = this.state.tableOptions[optionKey] return ( ) }) }
{optionKey}
{ return (
You can put any component you want here, even another React Table!

{ return (
It even has access to the row data: {() => JSON.stringify(row, null, 2)}
) }} />
) }} />

Tip: Hold shift when sorting to multi-sort!
) } setTableOption (event) { const target = event.target const value = target.type === 'checkbox' ? target.checked : target.value const name = target.name this.setState({ tableOptions: { ...this.state.tableOptions, [name]: value } }) } } // Source Code const CodeHighlight = require('./components/codeHighlight').default const source = require('!raw!./SubComponents') export default () => (
{() => source}
)