mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
add number filter stories
This commit is contained in:
parent
28a1077bad
commit
b0f411e934
74
packages/react-bootstrap-table2-example/examples/column-filter/custom-number-filter.js
vendored
Normal file
74
packages/react-bootstrap-table2-example/examples/column-filter/custom-number-filter.js
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter, Comparator } from 'react-bootstrap-table2-filter';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsGenerator(8);
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter({
|
||||
options: [2100, 2103, 2105],
|
||||
delay: 600,
|
||||
placeholder: 'custom placeholder',
|
||||
withoutEmptyComparatorOption: true,
|
||||
comparators: [Comparator.EQ, Comparator.GT, Comparator.LT],
|
||||
style: { display: 'inline-grid' },
|
||||
className: 'custom-numberfilter-class',
|
||||
comparatorStyle: { backgroundColor: 'antiquewhite' },
|
||||
comparatorClassName: 'custom-comparator-class',
|
||||
numberStyle: { backgroundColor: 'cadetblue', margin: '0px' },
|
||||
numberClassName: 'custom-number-class'
|
||||
})
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter, Comparator } from 'react-bootstrap-table2-filter';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter({
|
||||
options: [2100, 2103, 2105],
|
||||
delay: 600,
|
||||
placeholder: 'custom placeholder',
|
||||
withoutEmptyComparatorOption: true,
|
||||
comparators: [Comparator.EQ, Comparator.GT, Comparator.LT],
|
||||
style: { display: 'inline-grid' },
|
||||
className: 'custom-numberfilter-class',
|
||||
comparatorStyle: { backgroundColor: 'antiquewhite' },
|
||||
comparatorClassName: 'custom-comparator-class',
|
||||
numberStyle: { backgroundColor: 'cadetblue', margin: '0px' },
|
||||
numberClassName: 'custom-number-class'
|
||||
})
|
||||
}];
|
||||
|
||||
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
filter={ filterFactory() }
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
54
packages/react-bootstrap-table2-example/examples/column-filter/number-filter-default-value.js
vendored
Normal file
54
packages/react-bootstrap-table2-example/examples/column-filter/number-filter-default-value.js
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
import React from 'react';
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter, Comparator } from 'react-bootstrap-table2-filter';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsGenerator(8);
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter({
|
||||
defaultValue: { number: 2103, comparator: Comparator.GT }
|
||||
})
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter, Comparator } from 'react-bootstrap-table2-filter';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter({
|
||||
defaultValue: { number: 2103, comparator: Comparator.GT }
|
||||
})
|
||||
}];
|
||||
|
||||
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
filter={ filterFactory() }
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
50
packages/react-bootstrap-table2-example/examples/column-filter/number-filter.js
vendored
Normal file
50
packages/react-bootstrap-table2-example/examples/column-filter/number-filter.js
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter } from 'react-bootstrap-table2-filter';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const products = productsGenerator(8);
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter()
|
||||
}];
|
||||
|
||||
const sourceCode = `\
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import filterFactory, { numberFilter } from 'react-bootstrap-table2-filter';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price',
|
||||
filter: numberFilter()
|
||||
}];
|
||||
|
||||
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
filter={ filterFactory() }
|
||||
/>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
@ -43,6 +43,9 @@ import SelectFilter from 'examples/column-filter/select-filter';
|
||||
import SelectFilterWithDefaultValue from 'examples/column-filter/select-filter-default-value';
|
||||
import SelectFilterComparator from 'examples/column-filter/select-filter-like-comparator';
|
||||
import CustomSelectFilter from 'examples/column-filter/custom-select-filter';
|
||||
import NumberFilter from 'examples/column-filter/number-filter';
|
||||
import NumberFilterWithDefaultValue from 'examples/column-filter/number-filter-default-value';
|
||||
import CustomNumberFilter from 'examples/column-filter/custom-number-filter';
|
||||
|
||||
// work on rows
|
||||
import RowStyleTable from 'examples/rows/row-style';
|
||||
@ -143,12 +146,15 @@ storiesOf('Column Filter', module)
|
||||
.add('Text Filter', () => <TextFilter />)
|
||||
.add('Text Filter with Default Value', () => <TextFilterWithDefaultValue />)
|
||||
.add('Text Filter with Comparator', () => <TextFilterComparator />)
|
||||
.add('Custom Text Filter', () => <CustomTextFilter />)
|
||||
// add another filter type example right here.
|
||||
.add('Select Filter', () => <SelectFilter />)
|
||||
.add('Select Filter with Default Value', () => <SelectFilterWithDefaultValue />)
|
||||
.add('Select Filter with Comparator', () => <SelectFilterComparator />)
|
||||
.add('Number Filter', () => <NumberFilter />)
|
||||
.add('Number Filter with Default Value', () => <NumberFilterWithDefaultValue />)
|
||||
.add('Custom Text Filter', () => <CustomTextFilter />)
|
||||
.add('Custom Select Filter', () => <CustomSelectFilter />)
|
||||
.add('Custom Number Filter', () => <CustomNumberFilter />)
|
||||
.add('Custom Filter Value', () => <CustomFilterValue />);
|
||||
|
||||
storiesOf('Work on Rows', module)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user