mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-29 05:30:05 +00:00
Compare commits
48 Commits
react-boot
...
react-boot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a7c1def5b | ||
|
|
77b8ed53bf | ||
|
|
6bc54ef3ec | ||
|
|
6168bd7532 | ||
|
|
36fa9b8630 | ||
|
|
737922a5a4 | ||
|
|
0f37fae23d | ||
|
|
ce7e05d7f9 | ||
|
|
067006eb72 | ||
|
|
8fa10e3b6f | ||
|
|
e2e6c51d40 | ||
|
|
fb724331d3 | ||
|
|
160dede412 | ||
|
|
363a43251f | ||
|
|
8ad0e65679 | ||
|
|
6d5cca0047 | ||
|
|
204e75c9c2 | ||
|
|
fc27c56cbb | ||
|
|
8436edba7e | ||
|
|
3606fa3b7b | ||
|
|
73e8701bde | ||
|
|
6d2493d537 | ||
|
|
1a1f6969cb | ||
|
|
d47a3757b8 | ||
|
|
ba7512969e | ||
|
|
955ee17939 | ||
|
|
497bf44192 | ||
|
|
fcefcf8c84 | ||
|
|
04e3af0bbb | ||
|
|
9f47fa009c | ||
|
|
0edf9c8891 | ||
|
|
df5024892c | ||
|
|
4448c3f28c | ||
|
|
196ae33295 | ||
|
|
7f1b7a6c97 | ||
|
|
a6ccafcc75 | ||
|
|
06d87299a3 | ||
|
|
5891ec1b93 | ||
|
|
c5d9e04c2c | ||
|
|
dba3da28c1 | ||
|
|
a0e09cd804 | ||
|
|
d0e70f7246 | ||
|
|
b93c683f17 | ||
|
|
f80e1ea66c | ||
|
|
7642bfa1a3 | ||
|
|
8f304a849f | ||
|
|
33c026c7e2 | ||
|
|
d84fd5c801 |
@@ -33,6 +33,7 @@
|
|||||||
* [pagination](#pagination)
|
* [pagination](#pagination)
|
||||||
* [filter](#filter)
|
* [filter](#filter)
|
||||||
* [onTableChange](#onTableChange)
|
* [onTableChange](#onTableChange)
|
||||||
|
* [onDataSizeChange](#onDataSizeChange)
|
||||||
|
|
||||||
### <a name='keyField'>keyField(**required**) - [String]</a>
|
### <a name='keyField'>keyField(**required**) - [String]</a>
|
||||||
Tells `react-bootstrap-table2` which column is unique.
|
Tells `react-bootstrap-table2` which column is unique.
|
||||||
@@ -318,3 +319,19 @@ Following is a shape of `newState`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### <a name='onDataSizeChange'>onDataSizeChange - [Function]</a>
|
||||||
|
This callback function will be called only when data size change by search/filter etc. This function have one argument which is an object contains below props:
|
||||||
|
|
||||||
|
* `dataSize`: The new data size
|
||||||
|
|
||||||
|
```js
|
||||||
|
handleDataChange = ({ dataSize }) => {
|
||||||
|
this.setState({ rowCount: dataSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
<BootstrapTable
|
||||||
|
onDataSizeChange={ handleDataChange }
|
||||||
|
....
|
||||||
|
/>
|
||||||
|
```
|
||||||
@@ -164,7 +164,7 @@ Enable the column sort via a `true` value given.
|
|||||||
```
|
```
|
||||||
|
|
||||||
## <a name='sortCaret'>column.sortCaret - [Function]</a>
|
## <a name='sortCaret'>column.sortCaret - [Function]</a>
|
||||||
Use`column.sortCaret` to custom the sort caret. This callback function accept two arguments: `order` and `column`
|
Use`column.sortCaret` to customize the sort caret. This callback function accept two arguments: `order` and `column`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Row expand
|
# Row expand
|
||||||
`react-bootstrap-table2` supports the row expand feature. By passing prop `expandRow` to enable this functionality.
|
`react-bootstrap-table2` supports the row expand feature. By passing prop `expandRow` to enable this functionality.
|
||||||
|
|
||||||
> Default is click to expand/collapse a row. In addition, we don't support any way to chagne this mechanism!
|
> Default is click to expand/collapse a row. In addition, we don't support any way to change this mechanism!
|
||||||
|
|
||||||
## Required
|
## Required
|
||||||
* [renderer (**required**)](#renderer)
|
* [renderer (**required**)](#renderer)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
* [hideSelectAll](#hideSelectAll)
|
* [hideSelectAll](#hideSelectAll)
|
||||||
* [selectionRenderer](#selectionRenderer)
|
* [selectionRenderer](#selectionRenderer)
|
||||||
* [selectionHeaderRenderer](#selectionHeaderRenderer)
|
* [selectionHeaderRenderer](#selectionHeaderRenderer)
|
||||||
|
* [headerColumnStyle](#headerColumnStyle)
|
||||||
|
|
||||||
### <a name="mode">selectRow.mode - [String]</a>
|
### <a name="mode">selectRow.mode - [String]</a>
|
||||||
|
|
||||||
@@ -198,6 +199,31 @@ const selectRow = {
|
|||||||
|
|
||||||
> By default, `react-bootstrap-table2` will help you to handle the click event, it's not necessary to handle again by developer.
|
> By default, `react-bootstrap-table2` will help you to handle the click event, it's not necessary to handle again by developer.
|
||||||
|
|
||||||
|
|
||||||
|
### <a name='headerColumnStyle'>selectRow.headerColumnStyle - [Object | Function]</a>
|
||||||
|
A way to custome the selection header cell. `headerColumnStyle` not only accept a simple style object but also a callback function for more flexible customization:
|
||||||
|
|
||||||
|
### Style Object
|
||||||
|
|
||||||
|
```js
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
headerColumnStyle: { backgroundColor: 'blue' }
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### Callback Function
|
||||||
|
|
||||||
|
```js
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
headerColumnStyle: (status) => (
|
||||||
|
// status available value is checked, indeterminate and unchecked
|
||||||
|
return { backgroundColor: 'blue' };
|
||||||
|
)
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### <a name='onSelect'>selectRow.onSelect - [Function]</a>
|
### <a name='onSelect'>selectRow.onSelect - [Function]</a>
|
||||||
This callback function will be called when a row is select/unselect and pass following three arguments:
|
This callback function will be called when a row is select/unselect and pass following three arguments:
|
||||||
`row`, `isSelect`, `rowIndex` and `e`.
|
`row`, `isSelect`, `rowIndex` and `e`.
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ const columns = [
|
|||||||
if (typeof cell !== 'object') {
|
if (typeof cell !== 'object') {
|
||||||
dateObj = new Date(cell);
|
dateObj = new Date(cell);
|
||||||
}
|
}
|
||||||
return `${('0' + dateObj.getDate()).slice(-2)}/${('0' + (dateObj.getMonth() + 1)).slice(-2)}/${dateObj.getFullYear()}`;
|
return `${('0' + dateObj.getUTCDate()).slice(-2)}/${('0' + (dateObj.getUTCMonth() + 1)).slice(-2)}/${dateObj.getUTCFullYear()}`;
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
type: Type.DATE
|
type: Type.DATE
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-editor",
|
"name": "react-bootstrap-table2-editor",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"description": "it's the editor addon for react-bootstrap-table2",
|
"description": "it's the editor addon for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const sourceStylePath = path.join(__dirname, '../../react-bootstrap-table2/style
|
|||||||
const paginationStylePath = path.join(__dirname, '../../react-bootstrap-table2-paginator/style');
|
const paginationStylePath = path.join(__dirname, '../../react-bootstrap-table2-paginator/style');
|
||||||
const filterStylePath = path.join(__dirname, '../../react-bootstrap-table2-filter/style');
|
const filterStylePath = path.join(__dirname, '../../react-bootstrap-table2-filter/style');
|
||||||
const toolkitSourcePath = path.join(__dirname, '../../react-bootstrap-table2-toolkit/index.js');
|
const toolkitSourcePath = path.join(__dirname, '../../react-bootstrap-table2-toolkit/index.js');
|
||||||
|
const toolkitStylePath = path.join(__dirname, '../../react-bootstrap-table2-toolkit/style');
|
||||||
const storyPath = path.join(__dirname, '../stories');
|
const storyPath = path.join(__dirname, '../stories');
|
||||||
const examplesPath = path.join(__dirname, '../examples');
|
const examplesPath = path.join(__dirname, '../examples');
|
||||||
const srcPath = path.join(__dirname, '../src');
|
const srcPath = path.join(__dirname, '../src');
|
||||||
@@ -43,7 +44,13 @@ const loaders = [{
|
|||||||
}, {
|
}, {
|
||||||
test: /\.scss$/,
|
test: /\.scss$/,
|
||||||
use: ['style-loader', 'css-loader', 'sass-loader'],
|
use: ['style-loader', 'css-loader', 'sass-loader'],
|
||||||
include: [storyPath, sourceStylePath, paginationStylePath, filterStylePath],
|
include: [
|
||||||
|
storyPath,
|
||||||
|
sourceStylePath,
|
||||||
|
paginationStylePath,
|
||||||
|
filterStylePath,
|
||||||
|
toolkitStylePath
|
||||||
|
],
|
||||||
}, {
|
}, {
|
||||||
test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/,
|
test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/,
|
||||||
loader: 'url-loader?limit=100000',
|
loader: 'url-loader?limit=100000',
|
||||||
|
|||||||
@@ -45,8 +45,12 @@ class ExposedFunctionTable extends React.Component {
|
|||||||
console.log(this.node.table.props.data);
|
console.log(this.node.table.props.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleGetCurrentData = () => {
|
||||||
|
console.log(this.node.table.props.data);
|
||||||
|
}
|
||||||
|
|
||||||
handleGetSelectedData = () => {
|
handleGetSelectedData = () => {
|
||||||
console.log(this.node.selectionContext.state.selected);
|
console.log(this.node.selectionContext.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGetExpandedData = () => {
|
handleGetExpandedData = () => {
|
||||||
@@ -117,7 +121,7 @@ export default class ExposedFunctionTable extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleGetSelectedData = () => {
|
handleGetSelectedData = () => {
|
||||||
console.log(this.node.selectionContext.state.selected);
|
console.log(this.node.selectionContext.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGetExpandedData = () => {
|
handleGetExpandedData = () => {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const columns = [{
|
|||||||
if (typeof cell !== 'object') {
|
if (typeof cell !== 'object') {
|
||||||
dateObj = new Date(cell);
|
dateObj = new Date(cell);
|
||||||
}
|
}
|
||||||
return `${('0' + dateObj.getDate()).slice(-2)}/${('0' + (dateObj.getMonth() + 1)).slice(-2)}/${dateObj.getFullYear()}`;
|
return `${('0' + dateObj.getUTCDate()).slice(-2)}/${('0' + (dateObj.getUTCMonth() + 1)).slice(-2)}/${dateObj.getUTCFullYear()}`;
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
type: Type.DATE
|
type: Type.DATE
|
||||||
@@ -48,7 +48,7 @@ const columns = [{
|
|||||||
if (typeof cell !== 'object') {
|
if (typeof cell !== 'object') {
|
||||||
dateObj = new Date(cell);
|
dateObj = new Date(cell);
|
||||||
}
|
}
|
||||||
return \`$\{('0' + dateObj.getDate()).slice(-2)}/$\{('0' + (dateObj.getMonth() + 1)).slice(-2)}/$\{dateObj.getFullYear()}\`;
|
return \`$\{('0' + dateObj.getUTCDate()).slice(-2)}/$\{('0' + (dateObj.getUTCMonth() + 1)).slice(-2)}/$\{dateObj.getUTCFullYear()}\`;
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
type: Type.DATE
|
type: Type.DATE
|
||||||
|
|||||||
@@ -11,141 +11,13 @@ const products = [
|
|||||||
{ id: 14, name: 'Item 14', price: 14.5, inStock: true }
|
{ id: 14, name: 'Item 14', price: 14.5, inStock: true }
|
||||||
];
|
];
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
dataField: 'id',
|
|
||||||
text: 'Product ID'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'name',
|
|
||||||
text: 'Product Name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'price',
|
|
||||||
text: 'Product Price'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'inStock',
|
|
||||||
text: 'In Stock',
|
|
||||||
formatter: (cellContent, row) => (
|
|
||||||
<div className="checkbox disabled">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" checked={ row.inStock } disabled />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'df1',
|
|
||||||
isDummyField: true,
|
|
||||||
text: 'Action 1',
|
|
||||||
formatter: (cellContent, row) => {
|
|
||||||
if (row.inStock) {
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-success"> Available</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-danger"> Backordered</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'df2',
|
|
||||||
isDummyField: true,
|
|
||||||
text: 'Action 2',
|
|
||||||
formatter: (cellContent, row) => {
|
|
||||||
if (row.inStock) {
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-success"> Available</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-danger"> Backordered</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const sourceCode = `\
|
const sourceCode = `\
|
||||||
import BootstrapTable from 'react-bootstrap-table-next';
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
dataField: 'id',
|
|
||||||
text: 'Product ID'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'name',
|
|
||||||
text: 'Product Name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'price',
|
|
||||||
text: 'Product Price'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'inStock',
|
|
||||||
text: 'In Stock',
|
|
||||||
formatter: (cellContent, row) => (
|
|
||||||
<div className="checkbox disabled">
|
|
||||||
<label>
|
|
||||||
<input type="checkbox" checked={ row.inStock } disabled />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'df1',
|
|
||||||
isDummyField: true,
|
|
||||||
text: 'Action 1',
|
|
||||||
formatter: (cellContent, row) => {
|
|
||||||
if (row.inStock) {
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-success"> Available</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-danger"> Backordered</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
dataField: 'df2',
|
|
||||||
isDummyField: true,
|
|
||||||
text: 'Action 2',
|
|
||||||
formatter: (cellContent, row) => {
|
|
||||||
if (row.inStock) {
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-success"> Available</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<h5>
|
|
||||||
<span className="label label-danger"> Backordered</span>
|
|
||||||
</h5>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
class ProductList extends React.Component {
|
class ProductList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { products };
|
this.state = { products, count: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleInStock = () => {
|
toggleInStock = () => {
|
||||||
@@ -163,17 +35,96 @@ class ProductList extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID',
|
||||||
|
formatter: (cell, row, rowIndex, extraData) => (
|
||||||
|
<div>
|
||||||
|
<span>ID: {row.id}</span>
|
||||||
|
<br />
|
||||||
|
<span>state: {extraData}</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
formatExtraData: this.state.count
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'inStock',
|
||||||
|
text: 'In Stock',
|
||||||
|
formatter: (cellContent, row) => (
|
||||||
|
<div className="checkbox disabled">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" checked={ row.inStock } disabled />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'df1',
|
||||||
|
isDummyField: true,
|
||||||
|
text: 'Action 1',
|
||||||
|
formatter: (cellContent, row) => {
|
||||||
|
if (row.inStock) {
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-success"> Available</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-danger"> Backordered</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'df2',
|
||||||
|
isDummyField: true,
|
||||||
|
text: 'Action 2',
|
||||||
|
formatter: (cellContent, row) => {
|
||||||
|
if (row.inStock) {
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-success"> Available</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-danger"> Backordered</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1 className="h2">Products</h1>
|
<h3>Action 1 and Action 2 are dummy column</h3>
|
||||||
|
<button onClick={ this.toggleInStock } className="btn btn-primary">
|
||||||
|
Toggle item 13 stock status
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-success"
|
||||||
|
onClick={ () => this.setState(() => ({ count: this.state.count + 1 })) }
|
||||||
|
>
|
||||||
|
Click me to Increase counter
|
||||||
|
</button>
|
||||||
<BootstrapTable
|
<BootstrapTable
|
||||||
keyField="id"
|
keyField="id"
|
||||||
data={ this.state.products }
|
data={ this.state.products }
|
||||||
columns={ columns }
|
columns={ columns }
|
||||||
/>
|
/>
|
||||||
<button onClick={ this.toggleInStock } className="btn btn-primary">
|
<Code>{ sourceCode }</Code>
|
||||||
Toggle item 13 stock status
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -183,7 +134,7 @@ class ProductList extends React.Component {
|
|||||||
class ProductList extends React.Component {
|
class ProductList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { products };
|
this.state = { products, count: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleInStock = () => {
|
toggleInStock = () => {
|
||||||
@@ -200,13 +151,95 @@ class ProductList extends React.Component {
|
|||||||
this.setState(curr => ({ ...curr, products: newProducts }));
|
this.setState(curr => ({ ...curr, products: newProducts }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
counter = () => {
|
||||||
|
this.setState(curr => ({ ...curr, count: this.state.count + 1 }));
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID',
|
||||||
|
formatter: (cell, row, rowIndex, extraData) => (
|
||||||
|
<div>
|
||||||
|
<span>ID: {row.id}</span>
|
||||||
|
<br />
|
||||||
|
<span>Counter: {extraData}</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
formatExtraData: this.state.count
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'inStock',
|
||||||
|
text: 'In Stock',
|
||||||
|
formatter: (cellContent, row) => (
|
||||||
|
<div className="checkbox disabled">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" checked={ row.inStock } disabled />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'df1',
|
||||||
|
isDummyField: true,
|
||||||
|
text: 'Action 1',
|
||||||
|
formatter: (cellContent, row) => {
|
||||||
|
if (row.inStock) {
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-success"> Available</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-danger"> Backordered</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataField: 'df2',
|
||||||
|
isDummyField: true,
|
||||||
|
text: 'Action 2',
|
||||||
|
formatter: (cellContent, row) => {
|
||||||
|
if (row.inStock) {
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-success"> Available</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<h5>
|
||||||
|
<span className="label label-danger"> Backordered</span>
|
||||||
|
</h5>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h3>Action 1 and Action 2 are dummy column</h3>
|
<h3>Action 1 and Action 2 are dummy column</h3>
|
||||||
<button onClick={ this.toggleInStock } className="btn btn-primary">
|
<button onClick={ this.toggleInStock } className="btn btn-primary">
|
||||||
Toggle item 13 stock status
|
Toggle item 13 stock status
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-success"
|
||||||
|
onClick={ this.counter }
|
||||||
|
>
|
||||||
|
Click me to Increase counter
|
||||||
|
</button>
|
||||||
<BootstrapTable
|
<BootstrapTable
|
||||||
keyField="id"
|
keyField="id"
|
||||||
data={ this.state.products }
|
data={ this.state.products }
|
||||||
|
|||||||
102
packages/react-bootstrap-table2-example/examples/csv/export-only-filtered.js
vendored
Normal file
102
packages/react-bootstrap-table2-example/examples/csv/export-only-filtered.js
vendored
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/* eslint react/prop-types: 0 */
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import ToolkitProvider, { CSVExport, Search } from 'react-bootstrap-table2-toolkit';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
import paginationFactory from 'react-bootstrap-table2-paginator';
|
||||||
|
import Code from 'components/common/code-block';
|
||||||
|
import { productsGenerator } from 'utils/common';
|
||||||
|
|
||||||
|
const { SearchBar } = Search;
|
||||||
|
const { ExportCSVButton } = CSVExport;
|
||||||
|
const products = productsGenerator(150);
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID'
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name',
|
||||||
|
filter: textFilter()
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price'
|
||||||
|
}];
|
||||||
|
|
||||||
|
const sourceCode = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import ToolkitProvider, { CSVExport, Search } from 'react-bootstrap-table2-toolkit';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
|
||||||
|
const { SearchBar } = Search;
|
||||||
|
const { ExportCSVButton } = CSVExport;
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID'
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name'
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price'
|
||||||
|
}];
|
||||||
|
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true
|
||||||
|
};
|
||||||
|
|
||||||
|
<ToolkitProvider
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
exportCSV={ { onlyExportFiltered: true, exportAll: false } }
|
||||||
|
search
|
||||||
|
>
|
||||||
|
{
|
||||||
|
props => (
|
||||||
|
<div>
|
||||||
|
<ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
|
||||||
|
<hr />
|
||||||
|
<SearchBar { ...props.searchProps } />
|
||||||
|
<BootstrapTable
|
||||||
|
{ ...props.baseProps }
|
||||||
|
pagination={ paginationFactory() }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</ToolkitProvider>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<div>
|
||||||
|
<h3>Export all the filtered/searched rows</h3>
|
||||||
|
<ToolkitProvider
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
exportCSV={ { onlyExportFiltered: true, exportAll: false } }
|
||||||
|
search
|
||||||
|
>
|
||||||
|
{
|
||||||
|
props => (
|
||||||
|
<div>
|
||||||
|
<ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
|
||||||
|
<hr />
|
||||||
|
<SearchBar { ...props.searchProps } />
|
||||||
|
<BootstrapTable
|
||||||
|
{ ...props.baseProps }
|
||||||
|
pagination={ paginationFactory() }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</ToolkitProvider>
|
||||||
|
<Code>{ sourceCode }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
151
packages/react-bootstrap-table2-example/examples/data/data-change-listener.js
vendored
Normal file
151
packages/react-bootstrap-table2-example/examples/data/data-change-listener.js
vendored
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
/* eslint react/no-multi-comp: 0 */
|
||||||
|
import React from 'react';
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
import paginationFactory from 'react-bootstrap-table2-paginator';
|
||||||
|
import Code from 'components/common/code-block';
|
||||||
|
import { productsGenerator } from 'utils/common';
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID'
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name',
|
||||||
|
filter: textFilter()
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price',
|
||||||
|
filter: textFilter()
|
||||||
|
}];
|
||||||
|
|
||||||
|
const sourceCode1 = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
|
||||||
|
class Case1 extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { rowCount: products.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDataChange = ({ dataSize }) => {
|
||||||
|
this.setState({ rowCount: dataSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h5>Row Count:<span className="badge">{ this.state.rowCount }</span></h5>
|
||||||
|
<BootstrapTable
|
||||||
|
onDataSizeChange={ this.handleDataChange }
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const sourceCode2 = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
import paginationFactory from 'react-bootstrap-table2-paginator';
|
||||||
|
|
||||||
|
class Case2 extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { rowCount: products.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDataChange = ({ dataSize }) => {
|
||||||
|
this.setState({ rowCount: dataSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h5>Row Count:<span className="badge">{ this.state.rowCount }</span></h5>
|
||||||
|
<BootstrapTable
|
||||||
|
onDataSizeChange={ this.handleDataChange }
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
pagination={ paginationFactory() }
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const products1 = productsGenerator(8);
|
||||||
|
class WithoutPaginationCase extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { rowCount: products1.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDataChange = ({ dataSize }) => {
|
||||||
|
this.setState({ rowCount: dataSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3>Without Pagination Case</h3>
|
||||||
|
<h5>Row Count:<span className="badge">{ this.state.rowCount }</span></h5>
|
||||||
|
<BootstrapTable
|
||||||
|
onDataSizeChange={ this.handleDataChange }
|
||||||
|
keyField="id"
|
||||||
|
data={ products1 }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode2 }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const products2 = productsGenerator(88);
|
||||||
|
class WithPaginationCase extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { rowCount: products2.length };
|
||||||
|
}
|
||||||
|
|
||||||
|
handleDataChange = ({ dataSize }) => {
|
||||||
|
this.setState({ rowCount: dataSize });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h3>Without Pagination Case</h3>
|
||||||
|
<h5>Row Count:<span className="badge">{ this.state.rowCount }</span></h5>
|
||||||
|
<BootstrapTable
|
||||||
|
onDataSizeChange={ this.handleDataChange }
|
||||||
|
keyField="id"
|
||||||
|
data={ products2 }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
pagination={ paginationFactory() }
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode1 }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<div>
|
||||||
|
<WithoutPaginationCase />
|
||||||
|
<WithPaginationCase />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ const columns = [{
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
const expandRow = {
|
const expandRow = {
|
||||||
|
onlyOneExpanding: true,
|
||||||
renderer: row => (
|
renderer: row => (
|
||||||
<div>
|
<div>
|
||||||
<p>{ \`This Expand row is belong to rowKey $\{row.id}\` }</p>
|
<p>{ \`This Expand row is belong to rowKey $\{row.id}\` }</p>
|
||||||
|
|||||||
111
packages/react-bootstrap-table2-example/examples/row-selection/header-style.js
vendored
Normal file
111
packages/react-bootstrap-table2-example/examples/row-selection/header-style.js
vendored
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import Code from 'components/common/code-block';
|
||||||
|
import { productsGenerator } from 'utils/common';
|
||||||
|
|
||||||
|
const products = productsGenerator(2);
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID'
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name'
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price'
|
||||||
|
}];
|
||||||
|
|
||||||
|
const selectRow1 = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true,
|
||||||
|
headerColumnStyle: {
|
||||||
|
backgroundColor: 'blue'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceCode1 = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
|
||||||
|
const columns = ...
|
||||||
|
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true,
|
||||||
|
headerColumnStyle: {
|
||||||
|
backgroundColor: 'blue'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
selectRow={ selectRow }
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const selectRow2 = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true,
|
||||||
|
headerColumnStyle: (status) => {
|
||||||
|
if (status === 'checked') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'yellow'
|
||||||
|
};
|
||||||
|
} else if (status === 'indeterminate') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'pink'
|
||||||
|
};
|
||||||
|
} else if (status === 'unchecked') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'grey'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceCode2 = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
|
||||||
|
const columns = ...
|
||||||
|
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true,
|
||||||
|
headerColumnStyle: (status) => {
|
||||||
|
if (status === 'checked') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'yellow'
|
||||||
|
};
|
||||||
|
} else if (status === 'indeterminate') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'pink'
|
||||||
|
};
|
||||||
|
} else if (status === 'unchecked') {
|
||||||
|
return {
|
||||||
|
backgroundColor: 'grey'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
selectRow={ selectRow }
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<div>
|
||||||
|
<BootstrapTable keyField="id" data={ products } columns={ columns } selectRow={ selectRow1 } />
|
||||||
|
<Code>{ sourceCode1 }</Code>
|
||||||
|
<BootstrapTable keyField="id" data={ products } columns={ columns } selectRow={ selectRow2 } />
|
||||||
|
<Code>{ sourceCode2 }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-example",
|
"name": "react-bootstrap-table2-example",
|
||||||
"version": "1.0.20",
|
"version": "1.0.25",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ import SelectionWithExpansionTable from 'examples/row-selection/selection-with-e
|
|||||||
import SelectionNoDataTable from 'examples/row-selection/selection-no-data';
|
import SelectionNoDataTable from 'examples/row-selection/selection-no-data';
|
||||||
import SelectionStyleTable from 'examples/row-selection/selection-style';
|
import SelectionStyleTable from 'examples/row-selection/selection-style';
|
||||||
import SelectionClassTable from 'examples/row-selection/selection-class';
|
import SelectionClassTable from 'examples/row-selection/selection-class';
|
||||||
|
import HeaderStyleTable from 'examples/row-selection/header-style';
|
||||||
import HideSelectAllTable from 'examples/row-selection/hide-select-all';
|
import HideSelectAllTable from 'examples/row-selection/hide-select-all';
|
||||||
import CustomSelectionTable from 'examples/row-selection/custom-selection';
|
import CustomSelectionTable from 'examples/row-selection/custom-selection';
|
||||||
import NonSelectableRowsTable from 'examples/row-selection/non-selectable-rows';
|
import NonSelectableRowsTable from 'examples/row-selection/non-selectable-rows';
|
||||||
@@ -192,6 +193,7 @@ import CSVFormatter from 'examples/csv/csv-column-formatter';
|
|||||||
import CustomCSVHeader from 'examples/csv/custom-csv-header';
|
import CustomCSVHeader from 'examples/csv/custom-csv-header';
|
||||||
import HideCSVColumn from 'examples/csv/hide-column';
|
import HideCSVColumn from 'examples/csv/hide-column';
|
||||||
import ExportOnlySelected from 'examples/csv/export-only-selected';
|
import ExportOnlySelected from 'examples/csv/export-only-selected';
|
||||||
|
import ExportOnlyFiltered from 'examples/csv/export-only-filtered';
|
||||||
import CSVColumnType from 'examples/csv/csv-column-type';
|
import CSVColumnType from 'examples/csv/csv-column-type';
|
||||||
import CustomCSVButton from 'examples/csv/custom-csv-button';
|
import CustomCSVButton from 'examples/csv/custom-csv-button';
|
||||||
import ExportCustomData from 'examples/csv/export-custom-data';
|
import ExportCustomData from 'examples/csv/export-custom-data';
|
||||||
@@ -216,6 +218,7 @@ import RemoteCellEdit from 'examples/remote/remote-celledit';
|
|||||||
import RemoteAll from 'examples/remote/remote-all';
|
import RemoteAll from 'examples/remote/remote-all';
|
||||||
|
|
||||||
// data
|
// data
|
||||||
|
import DataChangeListener from 'examples/data/data-change-listener';
|
||||||
import LoadDataWithFilter from 'examples/data/load-data-on-the-fly-with-filter';
|
import LoadDataWithFilter from 'examples/data/load-data-on-the-fly-with-filter';
|
||||||
import LoadDataWithDefaultFilter from 'examples/data/load-data-on-the-fly-with-default-filter';
|
import LoadDataWithDefaultFilter from 'examples/data/load-data-on-the-fly-with-default-filter';
|
||||||
import LoadDataWithSearch from 'examples/data/load-data-on-the-fly-with-search';
|
import LoadDataWithSearch from 'examples/data/load-data-on-the-fly-with-search';
|
||||||
@@ -228,6 +231,7 @@ import 'stories/stylesheet/storybook.scss';
|
|||||||
import '../../react-bootstrap-table2/style/react-bootstrap-table2.scss';
|
import '../../react-bootstrap-table2/style/react-bootstrap-table2.scss';
|
||||||
import '../../react-bootstrap-table2-paginator/style/react-bootstrap-table2-paginator.scss';
|
import '../../react-bootstrap-table2-paginator/style/react-bootstrap-table2-paginator.scss';
|
||||||
import '../../react-bootstrap-table2-filter/style/react-bootstrap-table2-filter.scss';
|
import '../../react-bootstrap-table2-filter/style/react-bootstrap-table2-filter.scss';
|
||||||
|
import '../../react-bootstrap-table2-toolkit/style/react-bootstrap-table2-toolkit.scss';
|
||||||
|
|
||||||
// import bootstrap style by given version
|
// import bootstrap style by given version
|
||||||
import bootstrapStyle, { BOOTSTRAP_VERSION } from './bootstrap-style';
|
import bootstrapStyle, { BOOTSTRAP_VERSION } from './bootstrap-style';
|
||||||
@@ -382,6 +386,7 @@ storiesOf('Row Selection', module)
|
|||||||
.add('Selection without Data', () => <SelectionNoDataTable />)
|
.add('Selection without Data', () => <SelectionNoDataTable />)
|
||||||
.add('Selection Style', () => <SelectionStyleTable />)
|
.add('Selection Style', () => <SelectionStyleTable />)
|
||||||
.add('Selection Class', () => <SelectionClassTable />)
|
.add('Selection Class', () => <SelectionClassTable />)
|
||||||
|
.add('Custom Selection Column Header Style', () => <HeaderStyleTable />)
|
||||||
.add('Hide Select All', () => <HideSelectAllTable />)
|
.add('Hide Select All', () => <HideSelectAllTable />)
|
||||||
.add('Custom Selection', () => <CustomSelectionTable />)
|
.add('Custom Selection', () => <CustomSelectionTable />)
|
||||||
.add('Selection Background Color', () => <SelectionBgColorTable />)
|
.add('Selection Background Color', () => <SelectionBgColorTable />)
|
||||||
@@ -443,6 +448,7 @@ storiesOf('Export CSV', module)
|
|||||||
.add('Custom CSV Header', () => <CustomCSVHeader />)
|
.add('Custom CSV Header', () => <CustomCSVHeader />)
|
||||||
.add('Hide CSV Column', () => <HideCSVColumn />)
|
.add('Hide CSV Column', () => <HideCSVColumn />)
|
||||||
.add('Only Export Selected Rows', () => <ExportOnlySelected />)
|
.add('Only Export Selected Rows', () => <ExportOnlySelected />)
|
||||||
|
.add('Only Export Filtered/Searched Rows', () => <ExportOnlyFiltered />)
|
||||||
.add('CSV Column Type', () => <CSVColumnType />)
|
.add('CSV Column Type', () => <CSVColumnType />)
|
||||||
.add('Custom CSV Button', () => <CustomCSVButton />)
|
.add('Custom CSV Button', () => <CustomCSVButton />)
|
||||||
.add('Export Custom Data', () => <ExportCustomData />)
|
.add('Export Custom Data', () => <ExportCustomData />)
|
||||||
@@ -464,6 +470,7 @@ storiesOf('Remote', module)
|
|||||||
|
|
||||||
storiesOf('Data', module)
|
storiesOf('Data', module)
|
||||||
.addDecorator(bootstrapStyle())
|
.addDecorator(bootstrapStyle())
|
||||||
|
.add('Data Change Listener', () => <DataChangeListener />)
|
||||||
.add('Load data with Filter', () => <LoadDataWithFilter />)
|
.add('Load data with Filter', () => <LoadDataWithFilter />)
|
||||||
.add('Load data with Default Filter', () => <LoadDataWithDefaultFilter />)
|
.add('Load data with Default Filter', () => <LoadDataWithDefaultFilter />)
|
||||||
.add('Load data with Search', () => <LoadDataWithSearch />)
|
.add('Load data with Search', () => <LoadDataWithSearch />)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-filter",
|
"name": "react-bootstrap-table2-filter",
|
||||||
"version": "1.1.6",
|
"version": "1.1.9",
|
||||||
"description": "it's a column filter addon for react-bootstrap-table2",
|
"description": "it's a column filter addon for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const legalComparators = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
function dateParser(d) {
|
function dateParser(d) {
|
||||||
return `${d.getFullYear()}-${('0' + (d.getMonth() + 1)).slice(-2)}-${('0' + d.getDate()).slice(-2)}`;
|
return `${d.getUTCFullYear()}-${('0' + (d.getUTCMonth() + 1)).slice(-2)}-${('0' + d.getUTCDate()).slice(-2)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
class DateFilter extends Component {
|
class DateFilter extends Component {
|
||||||
@@ -132,8 +132,14 @@ class DateFilter extends Component {
|
|||||||
className={ `filter date-filter ${className}` }
|
className={ `filter date-filter ${className}` }
|
||||||
style={ style }
|
style={ style }
|
||||||
>
|
>
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `date-filter-comparator-${text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">Filter comparator</span>
|
||||||
<select
|
<select
|
||||||
ref={ n => this.dateFilterComparator = n }
|
ref={ n => this.dateFilterComparator = n }
|
||||||
|
id={ `date-filter-comparator-${text}` }
|
||||||
style={ comparatorStyle }
|
style={ comparatorStyle }
|
||||||
className={ `date-filter-comparator form-control ${comparatorClassName}` }
|
className={ `date-filter-comparator form-control ${comparatorClassName}` }
|
||||||
onChange={ this.onChangeComparator }
|
onChange={ this.onChangeComparator }
|
||||||
@@ -141,8 +147,12 @@ class DateFilter extends Component {
|
|||||||
>
|
>
|
||||||
{ this.getComparatorOptions() }
|
{ this.getComparatorOptions() }
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
|
<label htmlFor={ `date-filter-column-${text}` }>
|
||||||
|
<span className="sr-only">Enter ${ text }</span>
|
||||||
<input
|
<input
|
||||||
ref={ n => this.inputDate = n }
|
ref={ n => this.inputDate = n }
|
||||||
|
id={ `date-filter-column-${text}` }
|
||||||
className={ `filter date-filter-input form-control ${dateClassName}` }
|
className={ `filter date-filter-input form-control ${dateClassName}` }
|
||||||
style={ dateStyle }
|
style={ dateStyle }
|
||||||
type="date"
|
type="date"
|
||||||
@@ -150,6 +160,7 @@ class DateFilter extends Component {
|
|||||||
placeholder={ placeholder || `Enter ${text}...` }
|
placeholder={ placeholder || `Enter ${text}...` }
|
||||||
defaultValue={ this.getDefaultDate() }
|
defaultValue={ this.getDefaultDate() }
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,9 +111,15 @@ class MultiSelectFilter extends Component {
|
|||||||
`filter select-filter form-control ${className} ${this.state.isSelected ? '' : 'placeholder-selected'}`;
|
`filter select-filter form-control ${className} ${this.state.isSelected ? '' : 'placeholder-selected'}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `multiselect-filter-column-${column.text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">Filter by {column.text}</span>
|
||||||
<select
|
<select
|
||||||
{ ...rest }
|
{ ...rest }
|
||||||
ref={ n => this.selectInput = n }
|
ref={ n => this.selectInput = n }
|
||||||
|
id={ `multiselect-filter-column-${column.text}` }
|
||||||
style={ style }
|
style={ style }
|
||||||
multiple
|
multiple
|
||||||
className={ selectClass }
|
className={ selectClass }
|
||||||
@@ -123,6 +129,7 @@ class MultiSelectFilter extends Component {
|
|||||||
>
|
>
|
||||||
{ this.getOptions() }
|
{ this.getOptions() }
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,28 +173,45 @@ class NumberFilter extends Component {
|
|||||||
className={ `filter number-filter ${className}` }
|
className={ `filter number-filter ${className}` }
|
||||||
style={ style }
|
style={ style }
|
||||||
>
|
>
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `number-filter-comparator-${column.text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">Filter comparator</span>
|
||||||
<select
|
<select
|
||||||
ref={ n => this.numberFilterComparator = n }
|
ref={ n => this.numberFilterComparator = n }
|
||||||
style={ comparatorStyle }
|
style={ comparatorStyle }
|
||||||
|
id={ `number-filter-comparator-${column.text}` }
|
||||||
className={ `number-filter-comparator form-control ${comparatorClassName}` }
|
className={ `number-filter-comparator form-control ${comparatorClassName}` }
|
||||||
onChange={ this.onChangeComparator }
|
onChange={ this.onChangeComparator }
|
||||||
defaultValue={ defaultValue ? defaultValue.comparator : '' }
|
defaultValue={ defaultValue ? defaultValue.comparator : '' }
|
||||||
>
|
>
|
||||||
{ this.getComparatorOptions() }
|
{ this.getComparatorOptions() }
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
{
|
{
|
||||||
options ?
|
options ?
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `number-filter-column-${column.text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">{`Select ${column.text}`}</span>
|
||||||
<select
|
<select
|
||||||
ref={ n => this.numberFilter = n }
|
ref={ n => this.numberFilter = n }
|
||||||
|
id={ `number-filter-column-${column.text}` }
|
||||||
style={ numberStyle }
|
style={ numberStyle }
|
||||||
className={ selectClass }
|
className={ selectClass }
|
||||||
onChange={ this.onChangeNumberSet }
|
onChange={ this.onChangeNumberSet }
|
||||||
defaultValue={ defaultValue ? defaultValue.number : '' }
|
defaultValue={ defaultValue ? defaultValue.number : '' }
|
||||||
>
|
>
|
||||||
{ this.getNumberOptions() }
|
{ this.getNumberOptions() }
|
||||||
</select> :
|
</select>
|
||||||
|
</label> :
|
||||||
|
<label htmlFor={ `number-filter-column-${column.text}` }>
|
||||||
|
<span className="sr-only">{`Enter ${column.text}`}</span>
|
||||||
<input
|
<input
|
||||||
ref={ n => this.numberFilter = n }
|
ref={ n => this.numberFilter = n }
|
||||||
|
id={ `number-filter-column-${column.text}` }
|
||||||
type="number"
|
type="number"
|
||||||
style={ numberStyle }
|
style={ numberStyle }
|
||||||
className={ `number-filter-input form-control ${numberClassName}` }
|
className={ `number-filter-input form-control ${numberClassName}` }
|
||||||
@@ -202,6 +219,7 @@ class NumberFilter extends Component {
|
|||||||
onChange={ this.onChangeNumber }
|
onChange={ this.onChangeNumber }
|
||||||
defaultValue={ defaultValue ? defaultValue.number : '' }
|
defaultValue={ defaultValue ? defaultValue.number : '' }
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { FILTER_TYPE } from '../const';
|
|||||||
|
|
||||||
function optionsEquals(currOpts, prevOpts) {
|
function optionsEquals(currOpts, prevOpts) {
|
||||||
if (Array.isArray(currOpts)) {
|
if (Array.isArray(currOpts)) {
|
||||||
|
if (currOpts.length === prevOpts.length) {
|
||||||
for (let i = 0; i < currOpts.length; i += 1) {
|
for (let i = 0; i < currOpts.length; i += 1) {
|
||||||
if (
|
if (
|
||||||
currOpts[i].value !== prevOpts[i].value ||
|
currOpts[i].value !== prevOpts[i].value ||
|
||||||
@@ -16,7 +17,9 @@ function optionsEquals(currOpts, prevOpts) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return currOpts.length === prevOpts.length;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
const keys = Object.keys(currOpts);
|
const keys = Object.keys(currOpts);
|
||||||
for (let i = 0; i < keys.length; i += 1) {
|
for (let i = 0; i < keys.length; i += 1) {
|
||||||
@@ -136,9 +139,15 @@ class SelectFilter extends Component {
|
|||||||
`filter select-filter form-control ${className} ${this.state.isSelected ? '' : 'placeholder-selected'}`;
|
`filter select-filter form-control ${className} ${this.state.isSelected ? '' : 'placeholder-selected'}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `select-filter-column-${column.text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">Filter by { column.text }</span>
|
||||||
<select
|
<select
|
||||||
{ ...rest }
|
{ ...rest }
|
||||||
ref={ n => this.selectInput = n }
|
ref={ n => this.selectInput = n }
|
||||||
|
id={ `select-filter-column-${column.text}` }
|
||||||
style={ style }
|
style={ style }
|
||||||
className={ selectClass }
|
className={ selectClass }
|
||||||
onChange={ this.filter }
|
onChange={ this.filter }
|
||||||
@@ -147,6 +156,7 @@ class SelectFilter extends Component {
|
|||||||
>
|
>
|
||||||
{ this.getOptions() }
|
{ this.getOptions() }
|
||||||
</select>
|
</select>
|
||||||
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,10 +94,16 @@ class TextFilter extends Component {
|
|||||||
|
|
||||||
// stopPropagation for onClick event is try to prevent sort was triggered.
|
// stopPropagation for onClick event is try to prevent sort was triggered.
|
||||||
return (
|
return (
|
||||||
|
<label
|
||||||
|
className="filter-label"
|
||||||
|
htmlFor={ `text-filter-column-${text}` }
|
||||||
|
>
|
||||||
|
<span className="sr-only">Filter by {text}</span>
|
||||||
<input
|
<input
|
||||||
{ ...rest }
|
{ ...rest }
|
||||||
ref={ n => this.input = n }
|
ref={ n => this.input = n }
|
||||||
type="text"
|
type="text"
|
||||||
|
id={ `text-filter-column-${text}` }
|
||||||
className={ `filter text-filter form-control ${className}` }
|
className={ `filter text-filter form-control ${className}` }
|
||||||
style={ style }
|
style={ style }
|
||||||
onChange={ this.filter }
|
onChange={ this.filter }
|
||||||
@@ -105,6 +111,7 @@ class TextFilter extends Component {
|
|||||||
placeholder={ placeholder || `Enter ${text}...` }
|
placeholder={ placeholder || `Enter ${text}...` }
|
||||||
value={ this.state.value }
|
value={ this.state.value }
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ export default (
|
|||||||
// let nextData = nextProps.data;
|
// let nextData = nextProps.data;
|
||||||
if (!isRemoteFiltering() && !_.isEqual(nextProps.data, this.data)) {
|
if (!isRemoteFiltering() && !_.isEqual(nextProps.data, this.data)) {
|
||||||
this.doFilter(nextProps, undefined, this.isEmitDataChange);
|
this.doFilter(nextProps, undefined, this.isEmitDataChange);
|
||||||
|
} else {
|
||||||
|
this.data = nextProps.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +91,10 @@ export default (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFiltered() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
doFilter(props, customResult, ignoreEmitDataChange = false) {
|
doFilter(props, customResult, ignoreEmitDataChange = false) {
|
||||||
let result = customResult;
|
let result = customResult;
|
||||||
|
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ export const filterByDate = _ => (
|
|||||||
customFilterValue
|
customFilterValue
|
||||||
) => {
|
) => {
|
||||||
if (!date || !comparator) return data;
|
if (!date || !comparator) return data;
|
||||||
const filterDate = date.getDate();
|
const filterDate = date.getUTCDate();
|
||||||
const filterMonth = date.getMonth();
|
const filterMonth = date.getUTCMonth();
|
||||||
const filterYear = date.getFullYear();
|
const filterYear = date.getUTCFullYear();
|
||||||
|
|
||||||
return data.filter((row) => {
|
return data.filter((row) => {
|
||||||
let valid = true;
|
let valid = true;
|
||||||
@@ -114,9 +114,9 @@ export const filterByDate = _ => (
|
|||||||
cell = new Date(cell);
|
cell = new Date(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetDate = cell.getDate();
|
const targetDate = cell.getUTCDate();
|
||||||
const targetMonth = cell.getMonth();
|
const targetMonth = cell.getUTCMonth();
|
||||||
const targetYear = cell.getFullYear();
|
const targetYear = cell.getUTCFullYear();
|
||||||
|
|
||||||
|
|
||||||
switch (comparator) {
|
switch (comparator) {
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.react-bootstrap-table > table > thead > tr > th .filter-label {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
.react-bootstrap-table > table > thead > tr > th .filter {
|
.react-bootstrap-table > table > thead > tr > th .filter {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-paginator",
|
"name": "react-bootstrap-table2-paginator",
|
||||||
"version": "2.0.4",
|
"version": "2.0.6",
|
||||||
"description": "it's the pagination addon for react-bootstrap-table2",
|
"description": "it's the pagination addon for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class PaginationDataProvider extends Provider {
|
|||||||
this.currPage = newPage;
|
this.currPage = newPage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nextProps.onDataSizeChange && nextProps.data.length !== this.props.data.length) {
|
||||||
|
nextProps.onDataSizeChange({ dataSize: nextProps.data.length });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isRemotePagination = () => this.props.isRemotePagination();
|
isRemotePagination = () => this.props.isRemotePagination();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export default ExtendBase =>
|
|||||||
alwaysShowAllBtns
|
alwaysShowAllBtns
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let pages;
|
let pages = [];
|
||||||
let endPage = totalPages;
|
let endPage = totalPages;
|
||||||
if (endPage <= 0) return [];
|
if (endPage <= 0) return [];
|
||||||
|
|
||||||
@@ -68,24 +68,42 @@ export default ExtendBase =>
|
|||||||
startPage = endPage - paginationSize + 1;
|
startPage = endPage - paginationSize + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startPage !== pageStartIndex && totalPages > paginationSize && withFirstAndLast) {
|
if (alwaysShowAllBtns) {
|
||||||
|
if (withFirstAndLast) {
|
||||||
pages = [firstPageText, prePageText];
|
pages = [firstPageText, prePageText];
|
||||||
} else if (totalPages > 1 || alwaysShowAllBtns) {
|
|
||||||
pages = [prePageText];
|
|
||||||
} else {
|
} else {
|
||||||
pages = [];
|
pages = [prePageText];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startPage !== pageStartIndex &&
|
||||||
|
totalPages > paginationSize &&
|
||||||
|
withFirstAndLast &&
|
||||||
|
pages.length === 0
|
||||||
|
) {
|
||||||
|
pages = [firstPageText, prePageText];
|
||||||
|
} else if (totalPages > 1 && pages.length === 0) {
|
||||||
|
pages = [prePageText];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = startPage; i <= endPage; i += 1) {
|
for (let i = startPage; i <= endPage; i += 1) {
|
||||||
if (i >= pageStartIndex) pages.push(i);
|
if (i >= pageStartIndex) pages.push(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endPage <= lastPage && pages.length > 1) {
|
if (alwaysShowAllBtns || (endPage <= lastPage && pages.length > 1)) {
|
||||||
pages.push(nextPageText);
|
pages.push(nextPageText);
|
||||||
}
|
}
|
||||||
if (endPage !== lastPage && withFirstAndLast) {
|
if ((endPage !== lastPage && withFirstAndLast) || (withFirstAndLast && alwaysShowAllBtns)) {
|
||||||
pages.push(lastPageText);
|
pages.push(lastPageText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if ((endPage <= lastPage && pages.length > 1) || alwaysShowAllBtns) {
|
||||||
|
// pages.push(nextPageText);
|
||||||
|
// }
|
||||||
|
// if (endPage !== lastPage && withFirstAndLast) {
|
||||||
|
// pages.push(lastPageText);
|
||||||
|
// }
|
||||||
|
|
||||||
return pages;
|
return pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,11 @@ Default is `true`. `false` will only export current data which display on table.
|
|||||||
#### onlyExportSelection - [bool]
|
#### onlyExportSelection - [bool]
|
||||||
Default is `false`. `true` will only export the data which is selected.
|
Default is `false`. `true` will only export the data which is selected.
|
||||||
|
|
||||||
|
#### onlyExportFiltered - [bool]
|
||||||
|
Default is `false`. `true` will only export the data which is filtered/searched.
|
||||||
|
|
||||||
|
>> When you configure this prop as true, you must turn off `exportAll`.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
## Column Toggle
|
## Column Toggle
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class ToolkitProvider extends statelessDecorator(React.Component) {
|
|||||||
ignoreHeader: PropTypes.bool,
|
ignoreHeader: PropTypes.bool,
|
||||||
noAutoBOM: PropTypes.bool,
|
noAutoBOM: PropTypes.bool,
|
||||||
exportAll: PropTypes.bool,
|
exportAll: PropTypes.bool,
|
||||||
|
onlyExportFiltered: PropTypes.bool,
|
||||||
onlyExportSelection: PropTypes.bool
|
onlyExportSelection: PropTypes.bool
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-toolkit",
|
"name": "react-bootstrap-table2-toolkit",
|
||||||
"version": "1.3.2",
|
"version": "1.4.2",
|
||||||
"description": "The toolkit for react-bootstrap-table2",
|
"description": "The toolkit for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const transform = (
|
|||||||
cellContent = m.formatter(cellContent, row, rowIndex, m.formatExtraData);
|
cellContent = m.formatter(cellContent, row, rowIndex, m.formatExtraData);
|
||||||
}
|
}
|
||||||
if (m.type === String) {
|
if (m.type === String) {
|
||||||
return `"${cellContent}"`;
|
return `"${`${cellContent}`.replace(/"/g, '""')}"`;
|
||||||
}
|
}
|
||||||
return cellContent;
|
return cellContent;
|
||||||
}).join(separator)).join('\n');
|
}).join(separator)).join('\n');
|
||||||
|
|||||||
@@ -27,19 +27,24 @@ export default Base =>
|
|||||||
data = source;
|
data = source;
|
||||||
} else if (options.exportAll) {
|
} else if (options.exportAll) {
|
||||||
data = this.props.data;
|
data = this.props.data;
|
||||||
|
} else if (options.onlyExportFiltered) {
|
||||||
|
const payload = {};
|
||||||
|
this.tableExposedAPIEmitter.emit('get.filtered.rows', payload);
|
||||||
|
data = payload.result;
|
||||||
} else {
|
} else {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
this.tableExposedAPIEmitter.emit('get.table.data', payload);
|
this.tableExposedAPIEmitter.emit('get.table.data', payload);
|
||||||
data = payload.result;
|
data = payload.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter data
|
// filter data by row selection
|
||||||
if (options.onlyExportSelection) {
|
if (options.onlyExportSelection) {
|
||||||
const payload = {};
|
const payload = {};
|
||||||
this.tableExposedAPIEmitter.emit('get.selected.rows', payload);
|
this.tableExposedAPIEmitter.emit('get.selected.rows', payload);
|
||||||
const selections = payload.result;
|
const selections = payload.result;
|
||||||
data = data.filter(row => !!selections.find(sel => row[keyField] === sel));
|
data = data.filter(row => !!selections.find(sel => row[keyField] === sel));
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = transform(data, meta, this._.get, options);
|
const content = transform(data, meta, this._.get, options);
|
||||||
save(content, options);
|
save(content, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,12 +54,19 @@ class SearchBar extends React.Component {
|
|||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
style,
|
style,
|
||||||
placeholder
|
placeholder,
|
||||||
|
tableId
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<label
|
||||||
|
htmlFor={ `search-bar-${tableId}` }
|
||||||
|
className="search-label"
|
||||||
|
>
|
||||||
|
<span className="sr-only">Search this table</span>
|
||||||
<input
|
<input
|
||||||
ref={ n => this.input = n }
|
ref={ n => this.input = n }
|
||||||
|
id={ `search-bar-${tableId}` }
|
||||||
type="text"
|
type="text"
|
||||||
style={ style }
|
style={ style }
|
||||||
onKeyUp={ () => this.onKeyup() }
|
onKeyUp={ () => this.onKeyup() }
|
||||||
@@ -68,6 +75,7 @@ class SearchBar extends React.Component {
|
|||||||
value={ this.state.value }
|
value={ this.state.value }
|
||||||
placeholder={ placeholder || SearchBar.defaultProps.placeholder }
|
placeholder={ placeholder || SearchBar.defaultProps.placeholder }
|
||||||
/>
|
/>
|
||||||
|
</label>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +86,8 @@ SearchBar.propTypes = {
|
|||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
delay: PropTypes.number,
|
delay: PropTypes.number,
|
||||||
searchText: PropTypes.string
|
searchText: PropTypes.string,
|
||||||
|
tableId: PropTypes.string
|
||||||
};
|
};
|
||||||
|
|
||||||
SearchBar.defaultProps = {
|
SearchBar.defaultProps = {
|
||||||
@@ -86,7 +95,8 @@ SearchBar.defaultProps = {
|
|||||||
style: {},
|
style: {},
|
||||||
placeholder: 'Search',
|
placeholder: 'Search',
|
||||||
delay: 250,
|
delay: 250,
|
||||||
searchText: ''
|
searchText: '',
|
||||||
|
tableId: '0'
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SearchBar;
|
export default SearchBar;
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ export default (options = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSearched() {
|
||||||
|
return this.state.data;
|
||||||
|
}
|
||||||
|
|
||||||
triggerListener(result) {
|
triggerListener(result) {
|
||||||
if (this.props.dataChangeListener) {
|
if (this.props.dataChangeListener) {
|
||||||
this.props.dataChangeListener.emit('filterChanged', result.length);
|
this.props.dataChangeListener.emit('filterChanged', result.length);
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.search-label {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table-next",
|
"name": "react-bootstrap-table-next",
|
||||||
"version": "3.0.1",
|
"version": "3.1.2",
|
||||||
"description": "Next generation of react-bootstrap-table",
|
"description": "Next generation of react-bootstrap-table",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classnames": "2.2.5",
|
"classnames": "2.2.5",
|
||||||
|
"react-transition-group": "2.5.3",
|
||||||
"underscore": "1.9.1"
|
"underscore": "1.9.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
this.validateProps();
|
this.validateProps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
if (nextProps.onDataSizeChange && !nextProps.pagination) {
|
||||||
|
if (nextProps.data.length !== this.props.data.length) {
|
||||||
|
nextProps.onDataSizeChange({ dataSize: nextProps.data.length });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Exposed APIs
|
// Exposed APIs
|
||||||
getData = () => {
|
getData = () => {
|
||||||
return this.visibleRows();
|
return this.visibleRows();
|
||||||
@@ -159,7 +167,8 @@ BootstrapTable.propTypes = {
|
|||||||
bgColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
bgColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||||
hideSelectColumn: PropTypes.bool,
|
hideSelectColumn: PropTypes.bool,
|
||||||
selectionRenderer: PropTypes.func,
|
selectionRenderer: PropTypes.func,
|
||||||
selectionHeaderRenderer: PropTypes.func
|
selectionHeaderRenderer: PropTypes.func,
|
||||||
|
headerColumnStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
||||||
}),
|
}),
|
||||||
expandRow: PropTypes.shape({
|
expandRow: PropTypes.shape({
|
||||||
renderer: PropTypes.func,
|
renderer: PropTypes.func,
|
||||||
@@ -192,6 +201,7 @@ BootstrapTable.propTypes = {
|
|||||||
onSort: PropTypes.func,
|
onSort: PropTypes.func,
|
||||||
onFilter: PropTypes.func,
|
onFilter: PropTypes.func,
|
||||||
onExternalFilter: PropTypes.func,
|
onExternalFilter: PropTypes.func,
|
||||||
|
onDataSizeChange: PropTypes.func,
|
||||||
// Inject from toolkit
|
// Inject from toolkit
|
||||||
search: PropTypes.shape({
|
search: PropTypes.shape({
|
||||||
searchText: PropTypes.string,
|
searchText: PropTypes.string,
|
||||||
|
|||||||
23
packages/react-bootstrap-table2/src/cell.js
vendored
23
packages/react-bootstrap-table2/src/cell.js
vendored
@@ -8,7 +8,7 @@ import _ from './utils';
|
|||||||
class Cell extends eventDelegater(Component) {
|
class Cell extends eventDelegater(Component) {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleEditingCell = this.handleEditingCell.bind(this);
|
this.createHandleEditingCell = this.createHandleEditingCell.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps) {
|
shouldComponentUpdate(nextProps) {
|
||||||
@@ -26,7 +26,7 @@ class Cell extends eventDelegater(Component) {
|
|||||||
// if (nextProps.formatter)
|
// if (nextProps.formatter)
|
||||||
|
|
||||||
shouldUpdate =
|
shouldUpdate =
|
||||||
nextProps.column.formatter ? !_.isEqual(this.props.row, nextProps.row) : false ||
|
(nextProps.column.formatter ? !_.isEqual(this.props.row, nextProps.row) : false) ||
|
||||||
this.props.column.hidden !== nextProps.column.hidden ||
|
this.props.column.hidden !== nextProps.column.hidden ||
|
||||||
this.props.rowIndex !== nextProps.rowIndex ||
|
this.props.rowIndex !== nextProps.rowIndex ||
|
||||||
this.props.columnIndex !== nextProps.columnIndex ||
|
this.props.columnIndex !== nextProps.columnIndex ||
|
||||||
@@ -43,17 +43,10 @@ class Cell extends eventDelegater(Component) {
|
|||||||
return shouldUpdate;
|
return shouldUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEditingCell(e) {
|
createHandleEditingCell = originFunc => (e) => {
|
||||||
const { column, onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this.props;
|
const { onStart, rowIndex, columnIndex, clickToEdit, dbclickToEdit } = this.props;
|
||||||
const { events } = column;
|
if ((clickToEdit || dbclickToEdit) && _.isFunction(originFunc)) {
|
||||||
if (events) {
|
originFunc(e);
|
||||||
if (clickToEdit) {
|
|
||||||
const customClick = events.onClick;
|
|
||||||
if (_.isFunction(customClick)) customClick(e);
|
|
||||||
} else if (dbclickToEdit) {
|
|
||||||
const customDbClick = events.onDoubleClick;
|
|
||||||
if (_.isFunction(customDbClick)) customDbClick(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (onStart) {
|
if (onStart) {
|
||||||
onStart(rowIndex, columnIndex);
|
onStart(rowIndex, columnIndex);
|
||||||
@@ -85,9 +78,9 @@ class Cell extends eventDelegater(Component) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (clickToEdit && editable) {
|
if (clickToEdit && editable) {
|
||||||
attrs.onClick = this.handleEditingCell;
|
attrs.onClick = this.createHandleEditingCell(attrs.onClick);
|
||||||
} else if (dbclickToEdit && editable) {
|
} else if (dbclickToEdit && editable) {
|
||||||
attrs.onDoubleClick = this.handleEditingCell;
|
attrs.onDoubleClick = this.createHandleEditingCell(attrs.onDoubleClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ const withContext = Base =>
|
|||||||
const exposedAPIEmitter = new EventEmitter();
|
const exposedAPIEmitter = new EventEmitter();
|
||||||
exposedAPIEmitter.on('get.table.data', payload => payload.result = this.table.getData());
|
exposedAPIEmitter.on('get.table.data', payload => payload.result = this.table.getData());
|
||||||
exposedAPIEmitter.on('get.selected.rows', payload => payload.result = this.selectionContext.getSelected());
|
exposedAPIEmitter.on('get.selected.rows', payload => payload.result = this.selectionContext.getSelected());
|
||||||
|
exposedAPIEmitter.on('get.filtered.rows', (payload) => {
|
||||||
|
if (this.searchContext) {
|
||||||
|
payload.result = this.searchContext.getSearched();
|
||||||
|
} else if (this.filterContext) {
|
||||||
|
payload.result = this.filterContext.getFiltered();
|
||||||
|
} else {
|
||||||
|
payload.result = this.table.getData();
|
||||||
|
}
|
||||||
|
});
|
||||||
props.registerExposedAPI(exposedAPIEmitter);
|
props.registerExposedAPI(exposedAPIEmitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +211,7 @@ const withContext = Base =>
|
|||||||
bootstrap4={ this.props.bootstrap4 }
|
bootstrap4={ this.props.bootstrap4 }
|
||||||
isRemotePagination={ this.isRemotePagination }
|
isRemotePagination={ this.isRemotePagination }
|
||||||
remoteEmitter={ this.remoteEmitter }
|
remoteEmitter={ this.remoteEmitter }
|
||||||
|
onDataSizeChange={ this.props.onDataSizeChange }
|
||||||
>
|
>
|
||||||
<this.PaginationContext.Consumer>
|
<this.PaginationContext.Consumer>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import dataOperator from '../store/operators';
|
import dataOperator from '../store/operators';
|
||||||
|
import _ from '../utils';
|
||||||
|
|
||||||
const RowExpandContext = React.createContext();
|
const RowExpandContext = React.createContext();
|
||||||
|
|
||||||
@@ -10,18 +11,35 @@ class RowExpandProvider extends React.Component {
|
|||||||
children: PropTypes.node.isRequired,
|
children: PropTypes.node.isRequired,
|
||||||
data: PropTypes.array.isRequired,
|
data: PropTypes.array.isRequired,
|
||||||
keyField: PropTypes.string.isRequired
|
keyField: PropTypes.string.isRequired
|
||||||
}
|
};
|
||||||
|
|
||||||
state = { expanded: this.props.expandRow.expanded || [] };
|
state = { expanded: this.props.expandRow.expanded || [],
|
||||||
|
isClosing: this.props.expandRow.isClosing || [] };
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
if (nextProps.expandRow) {
|
if (nextProps.expandRow) {
|
||||||
|
const nextExpanded = nextProps.expandRow.expanded || this.state.expanded;
|
||||||
|
const isClosing = this.state.expanded.reduce((acc, cur) => {
|
||||||
|
if (!nextExpanded.includes(cur)) {
|
||||||
|
acc.push(cur);
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
this.setState(() => ({
|
this.setState(() => ({
|
||||||
expanded: nextProps.expandRow.expanded || this.state.expanded
|
expanded: nextExpanded,
|
||||||
|
isClosing
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
this.setState(() => ({
|
||||||
|
expanded: this.state.expanded
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClosed = (closedRow) => {
|
||||||
|
this.setState({ isClosing: this.state.isClosing.filter(value => value !== closedRow) });
|
||||||
|
};
|
||||||
|
|
||||||
handleRowExpand = (rowKey, expanded, rowIndex, e) => {
|
handleRowExpand = (rowKey, expanded, rowIndex, e) => {
|
||||||
const { data, keyField, expandRow: { onExpand, onlyOneExpanding, nonExpandable } } = this.props;
|
const { data, keyField, expandRow: { onExpand, onlyOneExpanding, nonExpandable } } = this.props;
|
||||||
if (nonExpandable && nonExpandable.includes(rowKey)) {
|
if (nonExpandable && nonExpandable.includes(rowKey)) {
|
||||||
@@ -29,11 +47,15 @@ class RowExpandProvider extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let currExpanded = [...this.state.expanded];
|
let currExpanded = [...this.state.expanded];
|
||||||
|
let isClosing = [...this.state.isClosing];
|
||||||
|
|
||||||
if (expanded) {
|
if (expanded) {
|
||||||
if (onlyOneExpanding) currExpanded = [rowKey];
|
if (onlyOneExpanding) {
|
||||||
else currExpanded.push(rowKey);
|
isClosing = isClosing.concat(currExpanded);
|
||||||
|
currExpanded = [rowKey];
|
||||||
|
} else currExpanded.push(rowKey);
|
||||||
} else {
|
} else {
|
||||||
|
isClosing.push(rowKey);
|
||||||
currExpanded = currExpanded.filter(value => value !== rowKey);
|
currExpanded = currExpanded.filter(value => value !== rowKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,8 +63,8 @@ class RowExpandProvider extends React.Component {
|
|||||||
const row = dataOperator.getRowByRowId(data, keyField, rowKey);
|
const row = dataOperator.getRowByRowId(data, keyField, rowKey);
|
||||||
onExpand(row, expanded, rowIndex, e);
|
onExpand(row, expanded, rowIndex, e);
|
||||||
}
|
}
|
||||||
this.setState(() => ({ expanded: currExpanded }));
|
this.setState(() => ({ expanded: currExpanded, isClosing }));
|
||||||
}
|
};
|
||||||
|
|
||||||
handleAllRowExpand = (e, expandAll) => {
|
handleAllRowExpand = (e, expandAll) => {
|
||||||
const {
|
const {
|
||||||
@@ -60,7 +82,7 @@ class RowExpandProvider extends React.Component {
|
|||||||
if (expandAll) {
|
if (expandAll) {
|
||||||
currExpanded = expanded.concat(dataOperator.expandableKeys(data, keyField, nonExpandable));
|
currExpanded = expanded.concat(dataOperator.expandableKeys(data, keyField, nonExpandable));
|
||||||
} else {
|
} else {
|
||||||
currExpanded = expanded.filter(s => typeof data.find(d => d[keyField] === s) === 'undefined');
|
currExpanded = expanded.filter(s => typeof data.find(d => _.get(d, keyField) === s) === 'undefined');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onExpandAll) {
|
if (onExpandAll) {
|
||||||
@@ -68,7 +90,7 @@ class RowExpandProvider extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setState(() => ({ expanded: currExpanded }));
|
this.setState(() => ({ expanded: currExpanded }));
|
||||||
}
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data, keyField } = this.props;
|
const { data, keyField } = this.props;
|
||||||
@@ -78,6 +100,8 @@ class RowExpandProvider extends React.Component {
|
|||||||
...this.props.expandRow,
|
...this.props.expandRow,
|
||||||
nonExpandable: this.props.expandRow.nonExpandable,
|
nonExpandable: this.props.expandRow.nonExpandable,
|
||||||
expanded: this.state.expanded,
|
expanded: this.state.expanded,
|
||||||
|
isClosing: this.state.isClosing,
|
||||||
|
onClosed: this.onClosed,
|
||||||
isAnyExpands: dataOperator.isAnyExpands(data, keyField, this.state.expanded),
|
isAnyExpands: dataOperator.isAnyExpands(data, keyField, this.state.expanded),
|
||||||
onRowExpand: this.handleRowExpand,
|
onRowExpand: this.handleRowExpand,
|
||||||
onAllRowExpand: this.handleAllRowExpand
|
onAllRowExpand: this.handleAllRowExpand
|
||||||
|
|||||||
@@ -1,18 +1,37 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { CSSTransition } from 'react-transition-group';
|
||||||
|
|
||||||
const ExpandRow = ({ children, ...rest }) => (
|
const ExpandRow = ({ children, expanded, onClosed, ...rest }) => (
|
||||||
<tr className="expanding-row">
|
<tr>
|
||||||
<td { ...rest }>{ children }</td>
|
<td className="reset-expansion-style" { ...rest }>
|
||||||
|
<CSSTransition
|
||||||
|
appear
|
||||||
|
in={ expanded }
|
||||||
|
timeout={ 400 }
|
||||||
|
classNames="row-expand-slide"
|
||||||
|
onExited={ onClosed }
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div className="row-expansion-style">
|
||||||
|
{ children }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CSSTransition>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|
||||||
ExpandRow.propTypes = {
|
ExpandRow.propTypes = {
|
||||||
children: PropTypes.node
|
children: PropTypes.node,
|
||||||
|
expanded: PropTypes.bool,
|
||||||
|
onClosed: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpandRow.defaultProps = {
|
ExpandRow.defaultProps = {
|
||||||
children: null
|
children: null,
|
||||||
|
expanded: false,
|
||||||
|
onClosed: null
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ExpandRow;
|
export default ExpandRow;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export default (Component) => {
|
|||||||
const key = props.value;
|
const key = props.value;
|
||||||
|
|
||||||
const expanded = expandRow.expanded.includes(key);
|
const expanded = expandRow.expanded.includes(key);
|
||||||
|
const isClosing = expandRow.isClosing.includes(key);
|
||||||
const expandable = !expandRow.nonExpandable || !expandRow.nonExpandable.includes(key);
|
const expandable = !expandRow.nonExpandable || !expandRow.nonExpandable.includes(key);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
<Component
|
<Component
|
||||||
{ ...props }
|
{ ...props }
|
||||||
@@ -18,9 +18,11 @@ export default (Component) => {
|
|||||||
expandable={ expandable }
|
expandable={ expandable }
|
||||||
expandRow={ { ...expandRow } }
|
expandRow={ { ...expandRow } }
|
||||||
/>,
|
/>,
|
||||||
expanded ? <ExpandRow
|
expanded || isClosing ? <ExpandRow
|
||||||
key={ `${key}-expanding` }
|
key={ `${key}-expanding` }
|
||||||
colSpan={ props.visibleColumnSize }
|
colSpan={ props.visibleColumnSize }
|
||||||
|
expanded={ expanded }
|
||||||
|
onClosed={ () => expandRow.onClosed(key) }
|
||||||
>
|
>
|
||||||
{ expandRow.renderer(props.row) }
|
{ expandRow.renderer(props.row) }
|
||||||
</ExpandRow> : null
|
</ExpandRow> : null
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import React, { Component } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Const from '../const';
|
import Const from '../const';
|
||||||
import { BootstrapContext } from '../contexts/bootstrap';
|
import { BootstrapContext } from '../contexts/bootstrap';
|
||||||
|
import _ from '../utils';
|
||||||
|
|
||||||
export const CheckBox = ({ className, checked, indeterminate }) => (
|
export const CheckBox = ({ className, checked, indeterminate }) => (
|
||||||
<input
|
<input
|
||||||
@@ -28,7 +29,8 @@ export default class SelectionHeaderCell extends Component {
|
|||||||
checkedStatus: PropTypes.string,
|
checkedStatus: PropTypes.string,
|
||||||
onAllRowsSelect: PropTypes.func,
|
onAllRowsSelect: PropTypes.func,
|
||||||
hideSelectAll: PropTypes.bool,
|
hideSelectAll: PropTypes.bool,
|
||||||
selectionHeaderRenderer: PropTypes.func
|
selectionHeaderRenderer: PropTypes.func,
|
||||||
|
headerColumnStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -64,7 +66,13 @@ export default class SelectionHeaderCell extends Component {
|
|||||||
CHECKBOX_STATUS_CHECKED, CHECKBOX_STATUS_INDETERMINATE, ROW_SELECT_MULTIPLE
|
CHECKBOX_STATUS_CHECKED, CHECKBOX_STATUS_INDETERMINATE, ROW_SELECT_MULTIPLE
|
||||||
} = Const;
|
} = Const;
|
||||||
|
|
||||||
const { mode, checkedStatus, selectionHeaderRenderer, hideSelectAll } = this.props;
|
const {
|
||||||
|
mode,
|
||||||
|
checkedStatus,
|
||||||
|
selectionHeaderRenderer,
|
||||||
|
hideSelectAll,
|
||||||
|
headerColumnStyle
|
||||||
|
} = this.props;
|
||||||
if (hideSelectAll) {
|
if (hideSelectAll) {
|
||||||
return <th data-row-selection />;
|
return <th data-row-selection />;
|
||||||
}
|
}
|
||||||
@@ -79,6 +87,10 @@ export default class SelectionHeaderCell extends Component {
|
|||||||
attrs.onClick = this.handleCheckBoxClick;
|
attrs.onClick = this.handleCheckBoxClick;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attrs.style = _.isFunction(headerColumnStyle) ?
|
||||||
|
headerColumnStyle(checkedStatus) :
|
||||||
|
headerColumnStyle;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BootstrapContext.Consumer>
|
<BootstrapContext.Consumer>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export default ExtendBase =>
|
|||||||
return (
|
return (
|
||||||
nextProps.editingRowIdx === nextProps.rowIndex ||
|
nextProps.editingRowIdx === nextProps.rowIndex ||
|
||||||
(this.props.editingRowIdx === nextProps.rowIndex &&
|
(this.props.editingRowIdx === nextProps.rowIndex &&
|
||||||
nextProps.editingRowIdx === null)
|
nextProps.editingRowIdx === null) ||
|
||||||
|
this.props.editingRowIdx === nextProps.rowIndex
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ export default ExtendBase =>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < this.props.columns.length; i += 1) {
|
for (let i = 0; i < this.props.columns.length; i += 1) {
|
||||||
if (this.props.columns[i].hidden !== nextProps.columns[i].hidden) {
|
if (!_.isEqual(this.props.columns[i], nextProps.columns[i])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
import _ from '../utils';
|
||||||
|
|
||||||
export const matchRow = (keyField, id) => row => row[keyField] === id;
|
export const matchRow = (keyField, id) => row => _.get(row, keyField) === id;
|
||||||
|
|
||||||
export const getRowByRowId = (data, keyField, id) => data.find(matchRow(keyField, id));
|
export const getRowByRowId = (data, keyField, id) => data.find(matchRow(keyField, id));
|
||||||
|
|||||||
@@ -68,10 +68,6 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.expanding-row {
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td.react-bootstrap-table-editing-cell {
|
td.react-bootstrap-table-editing-cell {
|
||||||
.animated {
|
.animated {
|
||||||
animation-fill-mode: both;
|
animation-fill-mode: both;
|
||||||
@@ -161,4 +157,26 @@
|
|||||||
animation-name: bounceOut;
|
animation-name: bounceOut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.reset-expansion-style{
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.row-expansion-style{
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
.row-expand-slide-appear{
|
||||||
|
max-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.row-expand-slide-appear-active{
|
||||||
|
max-height: 1000px;
|
||||||
|
transition: max-height 3s linear;
|
||||||
|
}
|
||||||
|
.row-expand-slide-exit{
|
||||||
|
max-height: 1000px;
|
||||||
|
}
|
||||||
|
.row-expand-slide-exit-active{
|
||||||
|
max-height: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: max-height 400ms cubic-bezier(0, 0.95, 0, 0.95)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -124,10 +124,10 @@ describe('Cell', () => {
|
|||||||
onClick: sinon.stub()
|
onClick: sinon.stub()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
it('should calling custom onClick callback also', () => {
|
|
||||||
|
it('should call onStart correctly', () => {
|
||||||
wrapper.find('td').simulate('click');
|
wrapper.find('td').simulate('click');
|
||||||
expect(onStartCallBack.callCount).toBe(1);
|
expect(onStartCallBack.callCount).toBe(1);
|
||||||
expect(column.events.onClick.callCount).toBe(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -164,10 +164,10 @@ describe('Cell', () => {
|
|||||||
onDoubleClick: sinon.stub()
|
onDoubleClick: sinon.stub()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
it('should calling custom onDoubleClick callback also', () => {
|
|
||||||
|
it('should call onStart correctly', () => {
|
||||||
wrapper.find('td').simulate('doubleclick');
|
wrapper.find('td').simulate('doubleclick');
|
||||||
expect(onStartCallBack.callCount).toBe(1);
|
expect(onStartCallBack.callCount).toBe(1);
|
||||||
expect(column.events.onDoubleClick.callCount).toBe(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user