mirror of
https://github.com/gosticks/react-table.git
synced 2026-10-06 15:57:04 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8146b5d14 | ||
|
|
eef59a559e | ||
|
|
3b18e8c8c1 | ||
|
|
dd6b8af304 | ||
|
|
f242d2f3f6 | ||
|
|
9dd0333571 | ||
|
|
085616d858 | ||
|
|
25ef0b2273 | ||
|
|
1fef30311c | ||
|
|
5351f79293 | ||
|
|
0bb3f2421e | ||
|
|
c392c90eb6 | ||
|
|
fc5cc00fce | ||
|
|
a8c8211ef8 |
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
|
lib/
|
||||||
|
react-table.js
|
||||||
|
react-table.css
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -15,20 +15,28 @@ A fast, lightweight, opinionated table and datagrid built on React
|
|||||||
- Server-side data
|
- Server-side data
|
||||||
- Minimal design & easily themeable
|
- Minimal design & easily themeable
|
||||||
|
|
||||||
Why you may **not** want to use this component:
|
|
||||||
- No support for infinite scrolling yet. We chose to avoid the complex problems that come with it, and instead provide reliable and predictable pagination.
|
|
||||||
|
|
||||||
## [Demo](http://react-table.zabapps.com)
|
## [Demo](http://react-table.zabapps.com)
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
- [Installation](#nstallation)
|
||||||
|
- [Example](#example)
|
||||||
|
- [Data](#data)
|
||||||
|
- [Default Props](#default-props)
|
||||||
|
- [Columns](#columns)
|
||||||
|
- [Styles](#styles)
|
||||||
|
- [Header Groups](#header-groups)
|
||||||
|
- [Server-side Data](#server-side-data)
|
||||||
|
- [Multi-sort](#multi-sort)
|
||||||
|
- [Component Overrides](#component-overrides)
|
||||||
|
|
||||||
|
<a name="installation"></a>
|
||||||
## Installation
|
## Installation
|
||||||
```bash
|
```bash
|
||||||
$ npm install react-table
|
$ npm install react-table
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Styles
|
<a name="example"></a>
|
||||||
React-table is built to be dropped into existing applications or styled from the ground up, but if you'd like a decent starting point, you can optionally include our default theme `react-table.css`. We think it looks great, honestly :)
|
## Example
|
||||||
|
|
||||||
## Quick Usage
|
|
||||||
```javascript
|
```javascript
|
||||||
import ReactTable from 'react-table'
|
import ReactTable from 'react-table'
|
||||||
|
|
||||||
@@ -63,9 +71,125 @@ const columns = [{
|
|||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Client-side Data
|
<a name="data"></a>
|
||||||
To use client-side data, simply pass the `data` prop an array. Client-side filtering and pagination is built in, and your table will update gracefully if you change any props.
|
## Data
|
||||||
|
Every React-Table instance requires you to set the `data` prop. To use client-side data, simply pass the `data` prop anything that resembles an array or object. Client-side filtering and pagination is built in, and your table will update gracefully if you change any props. [Server-side data](#server-side-data) is also supported.
|
||||||
|
|
||||||
|
|
||||||
|
<a name="default-props"></a>
|
||||||
|
## Default Props
|
||||||
|
These are the default props for the main react component `<ReactTable />`
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
// General
|
||||||
|
pageSize: 20,
|
||||||
|
minRows: 0, // Ensure this many rows are always rendered, regardless of rows on page
|
||||||
|
|
||||||
|
// Text
|
||||||
|
previousText: 'Previous',
|
||||||
|
nextText: 'Next'
|
||||||
|
|
||||||
|
// Classes
|
||||||
|
className: '-striped -highlight', // The most top level className for the component
|
||||||
|
tableClassName: '', // ClassName for the `table` element
|
||||||
|
theadClassName: '', // ClassName for the `thead` element
|
||||||
|
tbodyClassName: '', // ClassName for the `tbody` element
|
||||||
|
trClassName: '', // ClassName for all `tr` elements
|
||||||
|
trClassCallback: row => null, // A call back to dynamically add classes (via the classnames module) to a row element
|
||||||
|
paginationClassName: '' // ClassName for `pagination` element
|
||||||
|
// Styles
|
||||||
|
style: {}, // Main style object for the component
|
||||||
|
tableStyle: {}, // style object for the `table` component
|
||||||
|
theadStyle: {}, // style object for the `thead` component
|
||||||
|
tbodyStyle: {}, // style object for the `tbody` component
|
||||||
|
trStyle: {}, // style object for the `tr` component
|
||||||
|
trStyleCallback: row => {}, // A call back to dynamically add styles to a row element
|
||||||
|
thStyle: {}, // style object for the `th` component
|
||||||
|
tdStyle: {}, // style object for the `td` component
|
||||||
|
paginationStyle: {}, // style object for the `paginination` component
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can easily override the core defaults like so:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { ReactTableDefaults } from 'react-table'
|
||||||
|
|
||||||
|
Object.assign(ReactTableDefaults, {
|
||||||
|
pageSize: 10,
|
||||||
|
minRows: 3,
|
||||||
|
// etc...
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Or just define them on the component per-instance
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
<ReactTable
|
||||||
|
pageSize={10}
|
||||||
|
minRows={3}
|
||||||
|
// etc...
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="columns"></a>
|
||||||
|
## Columns
|
||||||
|
Every React-Table instance requires a `columns` prop, which is an array of objects containing the following properties
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
[{
|
||||||
|
// General
|
||||||
|
accessor: 'propertyName' or Accessor eg. (row) => row.propertyName,
|
||||||
|
id: 'myProperty', // Conditional - A unique ID is required if the accessor is not a string or if you would like to override the column name used in server-side calls
|
||||||
|
sortable: true,
|
||||||
|
sort: 'asc' or 'desc',
|
||||||
|
show: true,
|
||||||
|
minWidth: Number // Allows the column to flex above this minimum amount
|
||||||
|
|
||||||
|
// Cell Options
|
||||||
|
className: '', // Set the classname of the `td` element of the column
|
||||||
|
style: {}, // Set the style of the `td` element of the column
|
||||||
|
innerClassName: '', // Set the classname of the `.-td-inner` element of the column
|
||||||
|
innerStyle: {}, // Set the style of the `.-td-inner` element of the column
|
||||||
|
render: JSX eg. ({row, value, index, viewIndex}) => <span>{value}</span>, // Provide a JSX element or stateless function to render whatever you want as the column's cell with access to the entire row
|
||||||
|
|
||||||
|
// Header & HeaderGroup Options
|
||||||
|
header: 'Header Name' or JSX eg. ({data, column}) => <div>Header Name</div>,
|
||||||
|
headerClassName: '', // Set the classname of the `th` element of the column
|
||||||
|
headerStyle: {}, // Set the style of the `th` element of the column
|
||||||
|
headerInnerClassName: '', // Set the classname of the `.-th-inner` element of the column
|
||||||
|
headerInnerStyle: {}, // Set the style of the `.th-inner` element of the column
|
||||||
|
|
||||||
|
// Header Groups only
|
||||||
|
columns: [...] // See Header Groups section below
|
||||||
|
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="styles"></a>
|
||||||
|
## Styles
|
||||||
|
React-table is built to be dropped into existing applications or styled from the ground up, but if you'd like a decent starting point, you can optionally include our default theme `react-table.css`. We think it looks great, honestly :)
|
||||||
|
|
||||||
|
<a name="header-groups"></a>
|
||||||
|
## Header Groups
|
||||||
|
To group columns with another header column, just nest your columns in a header column like so:
|
||||||
|
```javascript
|
||||||
|
const columns = [{
|
||||||
|
header: 'Favorites',
|
||||||
|
columns: [{
|
||||||
|
header: 'Color',
|
||||||
|
accessor: 'favorites.color'
|
||||||
|
}, {
|
||||||
|
header: 'Food',
|
||||||
|
accessor: 'favorites.food'
|
||||||
|
} {
|
||||||
|
header: 'Actor',
|
||||||
|
accessor: 'favorites.actor'
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="server-side-data"></a>
|
||||||
## Server-side Data
|
## Server-side Data
|
||||||
If you want to handle pagination, and sorting on the server, `react-table` makes it easy on you. Instead of passing the `data` prop an array, you provide a function instead.
|
If you want to handle pagination, and sorting on the server, `react-table` makes it easy on you. Instead of passing the `data` prop an array, you provide a function instead.
|
||||||
|
|
||||||
@@ -108,97 +232,11 @@ This function will be called on mount, pagination events, and sorting events. It
|
|||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="multi-sort"></a>
|
||||||
## Multi-Sort
|
## Multi-Sort
|
||||||
When clicking on a column header, hold shift to multi-sort! You can toggle `ascending` `descending` and `none` for multi-sort columns. Clicking on a header without holding shift will clear the multi-sort and replace it with the single sort of that column. It's quite handy!
|
When clicking on a column header, hold shift to multi-sort! You can toggle `ascending` `descending` and `none` for multi-sort columns. Clicking on a header without holding shift will clear the multi-sort and replace it with the single sort of that column. It's quite handy!
|
||||||
|
|
||||||
## Default Props
|
<a name="component-overrides"></a>
|
||||||
```javascript
|
|
||||||
{
|
|
||||||
// Classes
|
|
||||||
className: '-striped -highlight', // The most top level className for the component
|
|
||||||
tableClassName: '', // ClassName for the `table` element
|
|
||||||
theadClassName: '', // ClassName for the `thead` element
|
|
||||||
tbodyClassName: '', // ClassName for the `tbody` element
|
|
||||||
trClassName: '', // ClassName for all `tr` elements
|
|
||||||
paginationClassName: '' // ClassName for `pagination` element
|
|
||||||
//
|
|
||||||
pageSize: 20,
|
|
||||||
minRows: 0, // Ensure this many rows are always rendered, regardless of rows on page
|
|
||||||
// Global Column Defaults
|
|
||||||
column: { // default properties for every column's model
|
|
||||||
sortable: true,
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
// Text
|
|
||||||
previousText: 'Previous',
|
|
||||||
nextText: 'Next'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
You can easily override the core defaults like so:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import { ReactTableDefaults } from 'react-table'
|
|
||||||
|
|
||||||
Object.assign(ReactTableDefaults, {
|
|
||||||
pageSize: 10,
|
|
||||||
minRows: 3,
|
|
||||||
// etc...
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
Or just define them on the component
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
<ReactTable
|
|
||||||
pageSize={10}
|
|
||||||
minRows={3}
|
|
||||||
// etc...
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
|
|
||||||
## Column Props
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
[{
|
|
||||||
// Required
|
|
||||||
header: 'Header Name' or JSX eg. ({data, column}) => <div>Header Name</div>,
|
|
||||||
accessor: 'propertyName' or Accessor eg. (row) => row.propertyName,
|
|
||||||
|
|
||||||
// A unique ID is required if the accessor is not a string or if you would like to override the column name used in server-side calls
|
|
||||||
id: 'myProperty',
|
|
||||||
|
|
||||||
// Optional
|
|
||||||
className: '', // Set the classname of the `th/td` element of the column
|
|
||||||
innerClassName: '', // Set the classname of the `.th-inner/.td-inner` element of the column
|
|
||||||
columns: [...] // See Header Groups section below
|
|
||||||
render: JSX eg. ({row, value, index, viewIndex}) => <span>{value}</span>, // Provide a JSX element or stateless function to render whatever you want as the column's cell with access to the entire row
|
|
||||||
sortable: true,
|
|
||||||
sort: 'asc' or 'desc',
|
|
||||||
show: true,
|
|
||||||
width: Number, // Locks the column width to this amount
|
|
||||||
minWidth: Number // Allows the column to flex above this minimum amount
|
|
||||||
}]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Header Groups
|
|
||||||
To group columns with another header column, just nest your columns in a header column like so:
|
|
||||||
```javascript
|
|
||||||
const columns = [{
|
|
||||||
header: 'Favorites',
|
|
||||||
columns: [{
|
|
||||||
header: 'Color',
|
|
||||||
accessor: 'favorites.color'
|
|
||||||
}, {
|
|
||||||
header: 'Food',
|
|
||||||
accessor: 'favorites.food'
|
|
||||||
} {
|
|
||||||
header: 'Actor',
|
|
||||||
accessor: 'favorites.actor'
|
|
||||||
}]
|
|
||||||
}]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Component Overrides
|
## Component Overrides
|
||||||
Though we wouldn't suggest it, `react-table` has the ability to change the core componentry it used to render it's table. You can do so by assigning a react component to it's corresponding global prop, or on a one-off basis like so:
|
Though we wouldn't suggest it, `react-table` has the ability to change the core componentry it used to render it's table. You can do so by assigning a react component to it's corresponding global prop, or on a one-off basis like so:
|
||||||
```javascript
|
```javascript
|
||||||
|
|||||||
Vendored
+126
-47
File diff suppressed because one or more lines are too long
+122
-45
File diff suppressed because one or more lines are too long
+9
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-table",
|
"name": "react-table",
|
||||||
"version": "2.1.2",
|
"version": "2.2.2",
|
||||||
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
||||||
@@ -15,13 +15,20 @@
|
|||||||
"datagrid"
|
"datagrid"
|
||||||
],
|
],
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
|
"files": [
|
||||||
|
"lib/",
|
||||||
|
"react-table.js",
|
||||||
|
"react-table.css",
|
||||||
|
"media/*.png"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:node": "babel src --out-dir lib --source-maps inline",
|
"build:node": "babel src --out-dir lib --source-maps inline",
|
||||||
"build:css": "rm -rf react-table.css && stylus src/index.styl --use ./node_modules/nib/lib/nib.js --compress -o react-table.css",
|
"build:css": "rm -rf react-table.css && stylus src/index.styl --use ./node_modules/nib/lib/nib.js --compress -o react-table.css",
|
||||||
"watch": "onchange 'src/**' -i -- npm-run-all build:*",
|
"watch": "onchange 'src/**' -i -- npm-run-all build:*",
|
||||||
"test": "standard",
|
"test": "standard",
|
||||||
"umd": "rm -rf react-table.js && browserify lib/index.js -s reactTable -x react -t babelify -g uglifyify -o react-table.js",
|
"umd": "rm -rf react-table.js && browserify lib/index.js -s reactTable -x react -t babelify -g uglifyify -o react-table.js",
|
||||||
"prepublish": "npm-run-all build:* && npm run umd"
|
"prepublish": "npm-run-all build:* && npm run umd",
|
||||||
|
"postpublish": "git push --tags"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classnames": "^2.2.5"
|
"classnames": "^2.2.5"
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+108
-39
@@ -22,14 +22,36 @@ export const ReactTableDefaults = {
|
|||||||
theadClassName: '',
|
theadClassName: '',
|
||||||
tbodyClassName: '',
|
tbodyClassName: '',
|
||||||
trClassName: '',
|
trClassName: '',
|
||||||
|
trClassCallback: d => null,
|
||||||
|
thClassName: '',
|
||||||
|
thGroupClassName: '',
|
||||||
|
tdClassName: '',
|
||||||
paginationClassName: '',
|
paginationClassName: '',
|
||||||
|
// Styles
|
||||||
|
style: {},
|
||||||
|
tableStyle: {},
|
||||||
|
theadStyle: {},
|
||||||
|
tbodyStyle: {},
|
||||||
|
trStyle: {},
|
||||||
|
trStyleCallback: d => {},
|
||||||
|
thStyle: {},
|
||||||
|
tdStyle: {},
|
||||||
|
paginationStyle: {},
|
||||||
//
|
//
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
minRows: 0,
|
minRows: 0,
|
||||||
// Global Column Defaults
|
// Global Column Defaults
|
||||||
column: {
|
column: {
|
||||||
sortable: true,
|
sortable: true,
|
||||||
show: true
|
show: true,
|
||||||
|
className: '',
|
||||||
|
style: {},
|
||||||
|
innerClassName: '',
|
||||||
|
innerStyle: {},
|
||||||
|
headerClassName: '',
|
||||||
|
headerStyle: {},
|
||||||
|
headerInnerClassName: '',
|
||||||
|
headerInnerStyle: {}
|
||||||
},
|
},
|
||||||
// Text
|
// Text
|
||||||
previousText: 'Previous',
|
previousText: 'Previous',
|
||||||
@@ -96,17 +118,20 @@ export default React.createClass({
|
|||||||
}
|
}
|
||||||
const makeDecoratedColumn = (column) => {
|
const makeDecoratedColumn = (column) => {
|
||||||
const dcol = Object.assign({}, this.props.column, column)
|
const dcol = Object.assign({}, this.props.column, column)
|
||||||
|
|
||||||
if (typeof dcol.accessor === 'string') {
|
if (typeof dcol.accessor === 'string') {
|
||||||
dcol.id = dcol.id || dcol.accessor
|
dcol.id = dcol.id || dcol.accessor
|
||||||
const accessorString = dcol.accessor
|
const accessorString = dcol.accessor
|
||||||
dcol.accessor = row => _.get(row, accessorString)
|
dcol.accessor = row => _.get(row, accessorString)
|
||||||
|
return dcol
|
||||||
}
|
}
|
||||||
if (!dcol.id) {
|
|
||||||
console.warn('No column ID found for column: ', dcol)
|
if (dcol.accessor && !dcol.id) {
|
||||||
}
|
console.warn(dcol)
|
||||||
if (!dcol.accessor) {
|
throw new Error('A column id is required if using a non-string accessor for column above.')
|
||||||
console.warn('No column accessor found for column: ', dcol)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dcol.accessor = d => undefined
|
||||||
return dcol
|
return dcol
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,19 +277,35 @@ export default React.createClass({
|
|||||||
const NextComponent = this.props.nextComponent || defaultButton
|
const NextComponent = this.props.nextComponent || defaultButton
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classnames(this.props.className, 'ReactTable')}>
|
<div
|
||||||
<TableComponent className={classnames(this.props.tableClassName)}>
|
className={classnames(this.props.className, 'ReactTable')}
|
||||||
|
style={this.props.style}
|
||||||
|
>
|
||||||
|
<TableComponent
|
||||||
|
className={classnames(this.props.tableClassName)}
|
||||||
|
style={this.props.tableStyle}
|
||||||
|
>
|
||||||
{this.hasHeaderGroups && (
|
{this.hasHeaderGroups && (
|
||||||
<TheadComponent className={classnames(this.props.theadClassName, '-headerGroups')}>
|
<TheadComponent
|
||||||
<TrComponent className={this.props.trClassName}>
|
className={classnames(this.props.theadGroupClassName, '-headerGroups')}
|
||||||
|
style={this.props.theadStyle}
|
||||||
|
>
|
||||||
|
<TrComponent
|
||||||
|
className={this.props.trClassName}
|
||||||
|
style={this.props.trStyle}
|
||||||
|
>
|
||||||
{this.headerGroups.map((column, i) => {
|
{this.headerGroups.map((column, i) => {
|
||||||
return (
|
return (
|
||||||
<ThComponent
|
<ThComponent
|
||||||
key={i}
|
key={i}
|
||||||
className={classnames(column.className)}
|
colSpan={column.columns.length}
|
||||||
colSpan={column.columns.length}>
|
className={classnames(this.props.thClassname, column.headerClassName)}
|
||||||
|
style={Object.assign({}, this.props.thStyle, column.headerStyle)}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(column.innerClassName, '-th-inner')}>
|
className={classnames(column.headerInnerClassName, '-th-inner')}
|
||||||
|
style={Object.assign({}, this.props.thInnerStyle, column.headerInnerStyle)}
|
||||||
|
>
|
||||||
{typeof column.header === 'function' ? (
|
{typeof column.header === 'function' ? (
|
||||||
<column.header
|
<column.header
|
||||||
data={this.props.data}
|
data={this.props.data}
|
||||||
@@ -278,8 +319,14 @@ export default React.createClass({
|
|||||||
</TrComponent>
|
</TrComponent>
|
||||||
</TheadComponent>
|
</TheadComponent>
|
||||||
)}
|
)}
|
||||||
<TheadComponent className={classnames(this.props.theadClassName)}>
|
<TheadComponent
|
||||||
<TrComponent className={this.props.trClassName}>
|
className={classnames(this.props.theadClassName)}
|
||||||
|
style={this.props.theadStyle}
|
||||||
|
>
|
||||||
|
<TrComponent
|
||||||
|
className={this.props.trClassName}
|
||||||
|
style={this.props.trStyle}
|
||||||
|
>
|
||||||
{this.decoratedColumns.map((column, i) => {
|
{this.decoratedColumns.map((column, i) => {
|
||||||
const sort = this.state.sorting.find(d => d.id === column.id)
|
const sort = this.state.sorting.find(d => d.id === column.id)
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function' ? column.show() : column.show
|
||||||
@@ -287,22 +334,25 @@ export default React.createClass({
|
|||||||
<ThComponent
|
<ThComponent
|
||||||
key={i}
|
key={i}
|
||||||
className={classnames(
|
className={classnames(
|
||||||
column.className,
|
this.props.thClassname,
|
||||||
|
column.headerClassName,
|
||||||
sort ? (sort.asc ? '-sort-asc' : '-sort-desc') : '',
|
sort ? (sort.asc ? '-sort-asc' : '-sort-desc') : '',
|
||||||
{
|
{
|
||||||
'-cursor-pointer': column.sortable,
|
'-cursor-pointer': column.sortable,
|
||||||
'-hidden': !show
|
'-hidden': !show
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
|
style={Object.assign({}, this.props.thStyle, column.headerStyle)}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
column.sortable && this.sortColumn(column, e.shiftKey)
|
column.sortable && this.sortColumn(column, e.shiftKey)
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(column.innerClassName, '-th-inner')}
|
className={classnames(column.headerInnerClassName, '-th-inner')}
|
||||||
style={{
|
style={Object.assign({}, column.headerInnerStyle, {
|
||||||
width: column.width + 'px',
|
|
||||||
minWidth: column.minWidth + 'px'
|
minWidth: column.minWidth + 'px'
|
||||||
}}>
|
})}
|
||||||
|
>
|
||||||
{typeof column.header === 'function' ? (
|
{typeof column.header === 'function' ? (
|
||||||
<column.header
|
<column.header
|
||||||
data={this.props.data}
|
data={this.props.data}
|
||||||
@@ -315,31 +365,41 @@ export default React.createClass({
|
|||||||
})}
|
})}
|
||||||
</TrComponent>
|
</TrComponent>
|
||||||
</TheadComponent>
|
</TheadComponent>
|
||||||
<TbodyComponent className={classnames(this.props.tbodyClassName)}>
|
<TbodyComponent
|
||||||
|
className={classnames(this.props.tbodyClassName)}
|
||||||
|
style={this.props.tbodyStyle}
|
||||||
|
>
|
||||||
{pageRows.map((row, i) => {
|
{pageRows.map((row, i) => {
|
||||||
|
const rowInfo = {
|
||||||
|
row: row.__original,
|
||||||
|
index: row.__index,
|
||||||
|
viewIndex: i
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<TrComponent
|
<TrComponent
|
||||||
className={classnames(this.props.trClassName)}
|
key={i}
|
||||||
key={i}>
|
className={classnames(this.props.trClassName, this.props.trClassCallback(rowInfo))}
|
||||||
|
style={Object.assign({}, this.props.trStyle, this.props.trStyleCallback(rowInfo))}
|
||||||
|
>
|
||||||
{this.decoratedColumns.map((column, i2) => {
|
{this.decoratedColumns.map((column, i2) => {
|
||||||
const Cell = column.render
|
const Cell = column.render
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function' ? column.show() : column.show
|
||||||
return (
|
return (
|
||||||
<TdComponent
|
<TdComponent
|
||||||
|
key={i2}
|
||||||
className={classnames(column.className, {hidden: !show})}
|
className={classnames(column.className, {hidden: !show})}
|
||||||
key={i2}>
|
style={Object.assign({}, this.props.tdStyle, column.style)}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(column.innerClassName, '-td-inner')}
|
className={classnames(column.innerClassName, '-td-inner')}
|
||||||
style={{
|
style={Object.assign({}, column.innerStyle, {
|
||||||
width: column.width + 'px',
|
|
||||||
minWidth: column.minWidth + 'px'
|
minWidth: column.minWidth + 'px'
|
||||||
}}>
|
})}
|
||||||
|
>
|
||||||
{typeof Cell === 'function' ? (
|
{typeof Cell === 'function' ? (
|
||||||
<Cell
|
<Cell
|
||||||
value={row[column.id]}
|
value={row[column.id]}
|
||||||
row={row.__original}
|
{...rowInfo}
|
||||||
index={row.__index}
|
|
||||||
viewIndex={i}
|
|
||||||
/>
|
/>
|
||||||
) : typeof Cell !== 'undefined' ? Cell
|
) : typeof Cell !== 'undefined' ? Cell
|
||||||
: row[column.id]}
|
: row[column.id]}
|
||||||
@@ -353,20 +413,24 @@ export default React.createClass({
|
|||||||
{padRows.map((row, i) => {
|
{padRows.map((row, i) => {
|
||||||
return (
|
return (
|
||||||
<TrComponent
|
<TrComponent
|
||||||
|
key={i}
|
||||||
className={classnames(this.props.trClassName, '-padRow')}
|
className={classnames(this.props.trClassName, '-padRow')}
|
||||||
key={i}>
|
style={this.props.trStyle}
|
||||||
|
>
|
||||||
{this.decoratedColumns.map((column, i2) => {
|
{this.decoratedColumns.map((column, i2) => {
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function' ? column.show() : column.show
|
||||||
return (
|
return (
|
||||||
<TdComponent
|
<TdComponent
|
||||||
|
key={i2}
|
||||||
className={classnames(column.className, {hidden: !show})}
|
className={classnames(column.className, {hidden: !show})}
|
||||||
key={i2}>
|
style={Object.assign({}, this.props.tdStyle, column.style)}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
className={classnames(column.innerClassName, '-td-inner')}
|
className={classnames(column.innerClassName, '-td-inner')}
|
||||||
style={{
|
style={Object.assign({}, column.innerStyle, {
|
||||||
width: column.width + 'px',
|
|
||||||
minWidth: column.minWidth + 'px'
|
minWidth: column.minWidth + 'px'
|
||||||
}}> </div>
|
})}
|
||||||
|
> </div>
|
||||||
</TdComponent>
|
</TdComponent>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@@ -376,11 +440,15 @@ export default React.createClass({
|
|||||||
</TbodyComponent>
|
</TbodyComponent>
|
||||||
</TableComponent>
|
</TableComponent>
|
||||||
{pagesLength > 1 && (
|
{pagesLength > 1 && (
|
||||||
<div className={classnames(this.props.paginationClassName, '-pagination')}>
|
<div
|
||||||
|
className={classnames(this.props.paginationClassName, '-pagination')}
|
||||||
|
style={this.props.paginationStyle}
|
||||||
|
>
|
||||||
<div className='-left'>
|
<div className='-left'>
|
||||||
<PreviousComponent
|
<PreviousComponent
|
||||||
onClick={canPrevious && ((e) => this.previousPage(e))}
|
onClick={canPrevious && ((e) => this.previousPage(e))}
|
||||||
disabled={!canPrevious}>
|
disabled={!canPrevious}
|
||||||
|
>
|
||||||
{this.props.previousText}
|
{this.props.previousText}
|
||||||
</PreviousComponent>
|
</PreviousComponent>
|
||||||
</div>
|
</div>
|
||||||
@@ -390,7 +458,8 @@ export default React.createClass({
|
|||||||
<div className='-right'>
|
<div className='-right'>
|
||||||
<NextComponent
|
<NextComponent
|
||||||
onClick={canNext && ((e) => this.nextPage(e))}
|
onClick={canNext && ((e) => this.nextPage(e))}
|
||||||
disabled={!canNext}>
|
disabled={!canNext}
|
||||||
|
>
|
||||||
{this.props.nextText}
|
{this.props.nextText}
|
||||||
</NextComponent>
|
</NextComponent>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user