mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-29 13:40:07 +00:00
Compare commits
16 Commits
react-boot
...
react-boot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2e6c51d40 | ||
|
|
fb724331d3 | ||
|
|
160dede412 | ||
|
|
363a43251f | ||
|
|
8ad0e65679 | ||
|
|
6d5cca0047 | ||
|
|
204e75c9c2 | ||
|
|
fc27c56cbb | ||
|
|
8436edba7e | ||
|
|
3606fa3b7b | ||
|
|
73e8701bde | ||
|
|
6d2493d537 | ||
|
|
1a1f6969cb | ||
|
|
d47a3757b8 | ||
|
|
ba7512969e | ||
|
|
955ee17939 |
@@ -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 }
|
||||||
|
....
|
||||||
|
/>
|
||||||
|
```
|
||||||
@@ -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',
|
||||||
|
|||||||
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>
|
||||||
|
);
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-example",
|
"name": "react-bootstrap-table2-example",
|
||||||
"version": "1.0.23",
|
"version": "1.0.24",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -217,6 +217,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';
|
||||||
@@ -229,6 +230,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';
|
||||||
@@ -466,6 +468,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.8",
|
"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": {
|
||||||
|
|||||||
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.5",
|
"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();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-toolkit",
|
"name": "react-bootstrap-table2-toolkit",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "The toolkit for react-bootstrap-table2",
|
"description": "The toolkit for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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.1.0",
|
"version": "3.1.1",
|
||||||
"description": "Next generation of react-bootstrap-table",
|
"description": "Next generation of react-bootstrap-table",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -192,6 +200,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,
|
||||||
|
|||||||
@@ -211,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>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,13 +17,17 @@ class RowExpandProvider extends React.Component {
|
|||||||
|
|
||||||
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) => {
|
const isClosing = this.state.expanded.reduce((acc, cur) => {
|
||||||
if (!nextProps.expandRow.expanded.includes(cur)) {
|
if (!nextExpanded.includes(cur)) {
|
||||||
acc.push(cur);
|
acc.push(cur);
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
this.setState(() => ({ expanded: nextProps.expandRow.expanded, isClosing }));
|
this.setState(() => ({
|
||||||
|
expanded: nextExpanded,
|
||||||
|
isClosing
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
this.setState(() => ({
|
this.setState(() => ({
|
||||||
expanded: this.state.expanded
|
expanded: this.state.expanded
|
||||||
|
|||||||
Reference in New Issue
Block a user