mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Merge pull request #1149 from react-bootstrap-table/develop
20191109 release
This commit is contained in:
commit
ec742a43f6
@ -32,6 +32,7 @@
|
|||||||
* [defaultSortDirection](#defaultSortDirection)
|
* [defaultSortDirection](#defaultSortDirection)
|
||||||
* [pagination](#pagination)
|
* [pagination](#pagination)
|
||||||
* [filter](#filter)
|
* [filter](#filter)
|
||||||
|
* [filterPosition](filterPosition)
|
||||||
* [onTableChange](#onTableChange)
|
* [onTableChange](#onTableChange)
|
||||||
* [onDataSizeChange](#onDataSizeChange)
|
* [onDataSizeChange](#onDataSizeChange)
|
||||||
|
|
||||||
@ -329,6 +330,9 @@ Following is a shape of `newState`
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### <a name='filterPosition'>filterPosition - [String]</a>
|
||||||
|
Available value is `inline`, `top` and `bottom`, default is `inline`. This prop decide where `react-bootstrap-table` render column filter.
|
||||||
|
|
||||||
### <a name='onDataSizeChange'>onDataSizeChange - [Function]</a>
|
### <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:
|
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:
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@
|
|||||||
"webpack-dev-server": "2.7.1"
|
"webpack-dev-server": "2.7.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classnames": "2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"prop-types": "15.5.10",
|
"prop-types": "15.5.10",
|
||||||
"react": "16.4.0",
|
"react": "16.4.0",
|
||||||
"react-dom": "16.4.0",
|
"react-dom": "16.4.0",
|
||||||
|
|||||||
93
packages/react-bootstrap-table2-example/examples/column-filter/filter-position.js
vendored
Normal file
93
packages/react-bootstrap-table2-example/examples/column-filter/filter-position.js
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import filterFactory, { textFilter } 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',
|
||||||
|
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';
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID',
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name',
|
||||||
|
filter: textFilter()
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price',
|
||||||
|
filter: textFilter()
|
||||||
|
}];
|
||||||
|
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="top"
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
const sourceCode2 = `\
|
||||||
|
import BootstrapTable from 'react-bootstrap-table-next';
|
||||||
|
import filterFactory, { textFilter } from 'react-bootstrap-table2-filter';
|
||||||
|
|
||||||
|
const columns = [{
|
||||||
|
dataField: 'id',
|
||||||
|
text: 'Product ID',
|
||||||
|
}, {
|
||||||
|
dataField: 'name',
|
||||||
|
text: 'Product Name',
|
||||||
|
filter: textFilter()
|
||||||
|
}, {
|
||||||
|
dataField: 'price',
|
||||||
|
text: 'Product Price',
|
||||||
|
filter: textFilter()
|
||||||
|
}];
|
||||||
|
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="bottom"
|
||||||
|
/>
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<div>
|
||||||
|
<BootstrapTable
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="top"
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode1 }</Code>
|
||||||
|
<BootstrapTable
|
||||||
|
keyField="id"
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="bottom"
|
||||||
|
/>
|
||||||
|
<Code>{ sourceCode2 }</Code>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
@ -8,14 +8,17 @@ const products = productsGenerator(8);
|
|||||||
|
|
||||||
const columns = [{
|
const columns = [{
|
||||||
dataField: 'id',
|
dataField: 'id',
|
||||||
text: 'Product ID'
|
text: 'Product ID',
|
||||||
|
footer: 'hello'
|
||||||
}, {
|
}, {
|
||||||
dataField: 'name',
|
dataField: 'name',
|
||||||
text: 'Product Name',
|
text: 'Product Name',
|
||||||
|
footer: 'hello',
|
||||||
filter: textFilter()
|
filter: textFilter()
|
||||||
}, {
|
}, {
|
||||||
dataField: 'price',
|
dataField: 'price',
|
||||||
text: 'Product Price',
|
text: 'Product Price',
|
||||||
|
footer: 'hello',
|
||||||
filter: textFilter()
|
filter: textFilter()
|
||||||
}];
|
}];
|
||||||
|
|
||||||
@ -39,6 +42,11 @@ const columns = [{
|
|||||||
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
|
<BootstrapTable keyField='id' data={ products } columns={ columns } filter={ filterFactory() } />
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const selectRow = {
|
||||||
|
mode: 'checkbox',
|
||||||
|
clickToSelect: true
|
||||||
|
};
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
<BootstrapTable
|
<BootstrapTable
|
||||||
@ -46,6 +54,8 @@ export default () => (
|
|||||||
data={ products }
|
data={ products }
|
||||||
columns={ columns }
|
columns={ columns }
|
||||||
filter={ filterFactory() }
|
filter={ filterFactory() }
|
||||||
|
filterPosition="bottom"
|
||||||
|
selectRow={ selectRow }
|
||||||
/>
|
/>
|
||||||
<Code>{ sourceCode }</Code>
|
<Code>{ sourceCode }</Code>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -92,6 +92,7 @@ import AdvanceCustomFilter from 'examples/column-filter/advance-custom-filter';
|
|||||||
import ClearAllFilters from 'examples/column-filter/clear-all-filters';
|
import ClearAllFilters from 'examples/column-filter/clear-all-filters';
|
||||||
import FilterHooks from 'examples/column-filter/filter-hooks';
|
import FilterHooks from 'examples/column-filter/filter-hooks';
|
||||||
import CustomFilterLogic from 'examples/column-filter/custom-filter-logic';
|
import CustomFilterLogic from 'examples/column-filter/custom-filter-logic';
|
||||||
|
import FilterPosition from 'examples/column-filter/filter-position';
|
||||||
|
|
||||||
// work on rows
|
// work on rows
|
||||||
import RowStyleTable from 'examples/rows/row-style';
|
import RowStyleTable from 'examples/rows/row-style';
|
||||||
@ -314,6 +315,7 @@ storiesOf('Column Filter', module)
|
|||||||
.add('Number Filter with Default Value', () => <NumberFilterWithDefaultValue />)
|
.add('Number Filter with Default Value', () => <NumberFilterWithDefaultValue />)
|
||||||
.add('Date Filter', () => <DateFilter />)
|
.add('Date Filter', () => <DateFilter />)
|
||||||
.add('Date Filter with Default Value', () => <DateFilterWithDefaultValue />)
|
.add('Date Filter with Default Value', () => <DateFilterWithDefaultValue />)
|
||||||
|
.add('Filter Position', () => <FilterPosition />)
|
||||||
.add('Custom Text Filter', () => <CustomTextFilter />)
|
.add('Custom Text Filter', () => <CustomTextFilter />)
|
||||||
.add('Custom Select Filter', () => <CustomSelectFilter />)
|
.add('Custom Select Filter', () => <CustomSelectFilter />)
|
||||||
.add('Custom Number Filter', () => <CustomNumberFilter />)
|
.add('Custom Number Filter', () => <CustomNumberFilter />)
|
||||||
|
|||||||
@ -330,3 +330,29 @@ Following properties is valid in `FILTER_TYPES`:
|
|||||||
* NUMBER
|
* NUMBER
|
||||||
* DATE
|
* DATE
|
||||||
* MULTISELECT
|
* MULTISELECT
|
||||||
|
|
||||||
|
### Position
|
||||||
|
Default filter is rendered inside the table column header, but you can choose to render them as a row by `filterPosition`:
|
||||||
|
|
||||||
|
#### Render in the top of table body
|
||||||
|
|
||||||
|
```js
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="top"
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Render in the bottom of table body
|
||||||
|
```js
|
||||||
|
<BootstrapTable
|
||||||
|
keyField='id'
|
||||||
|
data={ products }
|
||||||
|
columns={ columns }
|
||||||
|
filter={ filterFactory() }
|
||||||
|
filterPosition="bottom"
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|||||||
import cs from 'classnames';
|
import cs from 'classnames';
|
||||||
|
|
||||||
import Header from './header';
|
import Header from './header';
|
||||||
|
import Filters from './filters';
|
||||||
import Caption from './caption';
|
import Caption from './caption';
|
||||||
import Body from './body';
|
import Body from './body';
|
||||||
import Footer from './footer';
|
import Footer from './footer';
|
||||||
@ -65,7 +66,8 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
rowEvents,
|
rowEvents,
|
||||||
selectRow,
|
selectRow,
|
||||||
expandRow,
|
expandRow,
|
||||||
cellEdit
|
cellEdit,
|
||||||
|
filterPosition
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const tableWrapperClass = cs('react-bootstrap-table', wrapperClasses);
|
const tableWrapperClass = cs('react-bootstrap-table', wrapperClasses);
|
||||||
@ -77,6 +79,8 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
[bootstrap4 ? 'table-sm' : 'table-condensed']: condensed
|
[bootstrap4 ? 'table-sm' : 'table-condensed']: condensed
|
||||||
}, classes);
|
}, classes);
|
||||||
|
|
||||||
|
const hasFilters = columns.some(col => col.filter || col.filterRenderer);
|
||||||
|
|
||||||
const hasFooter = _.filter(columns, col => _.has(col, 'footer')).length > 0;
|
const hasFooter = _.filter(columns, col => _.has(col, 'footer')).length > 0;
|
||||||
|
|
||||||
const tableCaption = (caption && <Caption>{ caption }</Caption>);
|
const tableCaption = (caption && <Caption>{ caption }</Caption>);
|
||||||
@ -96,7 +100,19 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
onExternalFilter={ this.props.onExternalFilter }
|
onExternalFilter={ this.props.onExternalFilter }
|
||||||
selectRow={ selectRow }
|
selectRow={ selectRow }
|
||||||
expandRow={ expandRow }
|
expandRow={ expandRow }
|
||||||
|
filterPosition={ filterPosition }
|
||||||
/>
|
/>
|
||||||
|
{hasFilters && filterPosition !== Const.FILTERS_POSITION_INLINE && (
|
||||||
|
<Filters
|
||||||
|
columns={ columns }
|
||||||
|
className={ this.props.filtersClasses }
|
||||||
|
onSort={ this.props.onSort }
|
||||||
|
onFilter={ this.props.onFilter }
|
||||||
|
currFilters={ this.props.currFilters }
|
||||||
|
filterPosition={ this.props.filterPosition }
|
||||||
|
onExternalFilter={ this.props.onExternalFilter }
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Body
|
<Body
|
||||||
data={ this.getData() }
|
data={ this.getData() }
|
||||||
keyField={ keyField }
|
keyField={ keyField }
|
||||||
@ -135,7 +151,7 @@ BootstrapTable.propTypes = {
|
|||||||
remote: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
remote: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
||||||
pagination: PropTypes.bool
|
pagination: PropTypes.bool
|
||||||
})]),
|
})]),
|
||||||
noDataIndication: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
noDataIndication: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
||||||
striped: PropTypes.bool,
|
striped: PropTypes.bool,
|
||||||
bordered: PropTypes.bool,
|
bordered: PropTypes.bool,
|
||||||
hover: PropTypes.bool,
|
hover: PropTypes.bool,
|
||||||
@ -199,6 +215,12 @@ BootstrapTable.propTypes = {
|
|||||||
rowEvents: PropTypes.object,
|
rowEvents: PropTypes.object,
|
||||||
rowClasses: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
rowClasses: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
||||||
headerClasses: PropTypes.string,
|
headerClasses: PropTypes.string,
|
||||||
|
filtersClasses: PropTypes.string,
|
||||||
|
filterPosition: PropTypes.oneOf([
|
||||||
|
Const.FILTERS_POSITION_TOP,
|
||||||
|
Const.FILTERS_POSITION_INLINE,
|
||||||
|
Const.FILTERS_POSITION_BOTTOM
|
||||||
|
]),
|
||||||
footerClasses: PropTypes.string,
|
footerClasses: PropTypes.string,
|
||||||
defaultSorted: PropTypes.arrayOf(PropTypes.shape({
|
defaultSorted: PropTypes.arrayOf(PropTypes.shape({
|
||||||
dataField: PropTypes.string.isRequired,
|
dataField: PropTypes.string.isRequired,
|
||||||
@ -240,7 +262,8 @@ BootstrapTable.defaultProps = {
|
|||||||
cellEdit: {
|
cellEdit: {
|
||||||
mode: null,
|
mode: null,
|
||||||
nonEditableRows: []
|
nonEditableRows: []
|
||||||
}
|
},
|
||||||
|
filterPosition: Const.FILTERS_POSITION_INLINE
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BootstrapTable;
|
export default BootstrapTable;
|
||||||
|
|||||||
5
packages/react-bootstrap-table2/src/const.js
vendored
5
packages/react-bootstrap-table2/src/const.js
vendored
@ -12,5 +12,8 @@ export default {
|
|||||||
TYPE_STRING: 'string',
|
TYPE_STRING: 'string',
|
||||||
TYPE_NUMBER: 'number',
|
TYPE_NUMBER: 'number',
|
||||||
TYPE_BOOLEAN: 'bool',
|
TYPE_BOOLEAN: 'bool',
|
||||||
TYPE_DATE: 'date'
|
TYPE_DATE: 'date',
|
||||||
|
FILTERS_POSITION_INLINE: 'inline',
|
||||||
|
FILTERS_POSITION_TOP: 'top',
|
||||||
|
FILTERS_POSITION_BOTTOM: 'bottom'
|
||||||
};
|
};
|
||||||
|
|||||||
49
packages/react-bootstrap-table2/src/filters-cell.js
vendored
Normal file
49
packages/react-bootstrap-table2/src/filters-cell.js
vendored
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import _ from './utils';
|
||||||
|
|
||||||
|
const FiltersCell = (props) => {
|
||||||
|
const {
|
||||||
|
index, column, onExternalFilter,
|
||||||
|
currFilters, onFilter
|
||||||
|
} = props;
|
||||||
|
const { filterRenderer, filter } = column;
|
||||||
|
let filterElm;
|
||||||
|
const cellAttrs = {};
|
||||||
|
const cellStyle = {};
|
||||||
|
cellAttrs.style = cellStyle;
|
||||||
|
if (column.headerAlign) {
|
||||||
|
cellStyle.textAlign = _.isFunction(column.headerAlign)
|
||||||
|
? column.headerAlign(column, index)
|
||||||
|
: column.headerAlign;
|
||||||
|
}
|
||||||
|
if (column.filterRenderer) {
|
||||||
|
const onCustomFilter = onExternalFilter(column, filter.props.type);
|
||||||
|
filterElm = filterRenderer(onCustomFilter, column);
|
||||||
|
} else if (filter) {
|
||||||
|
filterElm = (
|
||||||
|
<filter.Filter
|
||||||
|
{ ...filter.props }
|
||||||
|
filterState={ currFilters[column.dataField] }
|
||||||
|
onFilter={ onFilter }
|
||||||
|
column={ column }
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return React.createElement('th', cellAttrs, filterElm);
|
||||||
|
};
|
||||||
|
|
||||||
|
FiltersCell.propTypes = {
|
||||||
|
index: PropTypes.number.isRequired,
|
||||||
|
column: PropTypes.object.isRequired,
|
||||||
|
currFilters: PropTypes.object.isRequired,
|
||||||
|
onFilter: PropTypes.func,
|
||||||
|
onExternalFilter: PropTypes.func
|
||||||
|
};
|
||||||
|
|
||||||
|
FiltersCell.defaultProps = {
|
||||||
|
onFilter: () => { },
|
||||||
|
onExternalFilter: () => { }
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FiltersCell;
|
||||||
69
packages/react-bootstrap-table2/src/filters.js
vendored
Normal file
69
packages/react-bootstrap-table2/src/filters.js
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* eslint react/require-default-props: 0 */
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import FiltersCell from './filters-cell';
|
||||||
|
import Const from './const';
|
||||||
|
|
||||||
|
const Filters = (props) => {
|
||||||
|
const {
|
||||||
|
columns,
|
||||||
|
onFilter,
|
||||||
|
currFilters,
|
||||||
|
filterPosition,
|
||||||
|
onExternalFilter,
|
||||||
|
className
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const filterColumns = [];
|
||||||
|
let showFiltersRow = false;
|
||||||
|
|
||||||
|
columns.forEach((column, i) => {
|
||||||
|
filterColumns.push(<FiltersCell
|
||||||
|
index={ i }
|
||||||
|
column={ column }
|
||||||
|
currFilters={ currFilters }
|
||||||
|
onExternalFilter={ onExternalFilter }
|
||||||
|
onFilter={ onFilter }
|
||||||
|
/>);
|
||||||
|
|
||||||
|
if (column.filterRenderer || column.filter) {
|
||||||
|
if (!showFiltersRow) {
|
||||||
|
showFiltersRow = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<tbody
|
||||||
|
className={ className }
|
||||||
|
style={ {
|
||||||
|
display:
|
||||||
|
filterPosition === Const.FILTERS_POSITION_TOP
|
||||||
|
? 'table-header-group'
|
||||||
|
: 'table-footer-group'
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
<tr>{filterColumns}</tr>
|
||||||
|
</tbody>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Filters.propTypes = {
|
||||||
|
columns: PropTypes.array.isRequired,
|
||||||
|
onFilter: PropTypes.func,
|
||||||
|
filterPosition: PropTypes.oneOf([
|
||||||
|
Const.FILTERS_POSITION_TOP,
|
||||||
|
Const.FILTERS_POSITION_INLINE,
|
||||||
|
Const.FILTERS_POSITION_BOTTOM
|
||||||
|
]),
|
||||||
|
currFilters: PropTypes.object,
|
||||||
|
onExternalFilter: PropTypes.func,
|
||||||
|
className: PropTypes.string
|
||||||
|
};
|
||||||
|
|
||||||
|
Filters.defaultProps = {
|
||||||
|
position: Const.FILTERS_POSITION_TOP
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Filters;
|
||||||
@ -21,6 +21,7 @@ class HeaderCell extends eventDelegater(React.Component) {
|
|||||||
isLastSorting,
|
isLastSorting,
|
||||||
onFilter,
|
onFilter,
|
||||||
currFilters,
|
currFilters,
|
||||||
|
filterPosition,
|
||||||
onExternalFilter
|
onExternalFilter
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@ -104,18 +105,20 @@ class HeaderCell extends eventDelegater(React.Component) {
|
|||||||
if (cellClasses) cellAttrs.className = cs(cellAttrs.className, cellClasses);
|
if (cellClasses) cellAttrs.className = cs(cellAttrs.className, cellClasses);
|
||||||
if (!_.isEmptyObject(cellStyle)) cellAttrs.style = cellStyle;
|
if (!_.isEmptyObject(cellStyle)) cellAttrs.style = cellStyle;
|
||||||
|
|
||||||
if (filterRenderer) {
|
if (filterPosition === Const.FILTERS_POSITION_INLINE) {
|
||||||
const onCustomFilter = onExternalFilter(column, filter.props.type);
|
if (filterRenderer) {
|
||||||
filterElm = filterRenderer(onCustomFilter, column);
|
const onCustomFilter = onExternalFilter(column, filter.props.type);
|
||||||
} else if (filter) {
|
filterElm = filterRenderer(onCustomFilter, column);
|
||||||
filterElm = (
|
} else if (filter) {
|
||||||
<filter.Filter
|
filterElm = (
|
||||||
{ ...filter.props }
|
<filter.Filter
|
||||||
filterState={ currFilters[column.dataField] }
|
{ ...filter.props }
|
||||||
onFilter={ onFilter }
|
filterState={ currFilters[column.dataField] }
|
||||||
column={ column }
|
onFilter={ onFilter }
|
||||||
/>
|
column={ column }
|
||||||
);
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const children = headerFormatter ?
|
const children = headerFormatter ?
|
||||||
@ -180,6 +183,8 @@ HeaderCell.propTypes = {
|
|||||||
sortCaret: PropTypes.func,
|
sortCaret: PropTypes.func,
|
||||||
isLastSorting: PropTypes.bool,
|
isLastSorting: PropTypes.bool,
|
||||||
onFilter: PropTypes.func,
|
onFilter: PropTypes.func,
|
||||||
|
filterPosition: PropTypes.oneOf([Const.FILTERS_POSITION_INLINE,
|
||||||
|
Const.FILTERS_POSITION_BOTTOM, Const.FILTERS_POSITION_TOP]),
|
||||||
currFilters: PropTypes.object,
|
currFilters: PropTypes.object,
|
||||||
onExternalFilter: PropTypes.func
|
onExternalFilter: PropTypes.func
|
||||||
};
|
};
|
||||||
|
|||||||
15
packages/react-bootstrap-table2/src/header.js
vendored
15
packages/react-bootstrap-table2/src/header.js
vendored
@ -18,9 +18,10 @@ const Header = (props) => {
|
|||||||
sortField,
|
sortField,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
selectRow,
|
selectRow,
|
||||||
|
expandRow,
|
||||||
currFilters,
|
currFilters,
|
||||||
onExternalFilter,
|
onExternalFilter,
|
||||||
expandRow
|
filterPosition
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
let SelectionHeaderCellComp = () => null;
|
let SelectionHeaderCellComp = () => null;
|
||||||
@ -50,11 +51,12 @@ const Header = (props) => {
|
|||||||
column={ column }
|
column={ column }
|
||||||
onSort={ onSort }
|
onSort={ onSort }
|
||||||
sorting={ currSort }
|
sorting={ currSort }
|
||||||
|
sortOrder={ sortOrder }
|
||||||
|
isLastSorting={ isLastSorting }
|
||||||
onFilter={ onFilter }
|
onFilter={ onFilter }
|
||||||
currFilters={ currFilters }
|
currFilters={ currFilters }
|
||||||
onExternalFilter={ onExternalFilter }
|
onExternalFilter={ onExternalFilter }
|
||||||
sortOrder={ sortOrder }
|
filterPosition={ filterPosition }
|
||||||
isLastSorting={ isLastSorting }
|
|
||||||
/>);
|
/>);
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
@ -94,7 +96,12 @@ Header.propTypes = {
|
|||||||
currFilters: PropTypes.object,
|
currFilters: PropTypes.object,
|
||||||
onExternalFilter: PropTypes.func,
|
onExternalFilter: PropTypes.func,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
expandRow: PropTypes.object
|
expandRow: PropTypes.object,
|
||||||
|
filterPosition: PropTypes.oneOf([
|
||||||
|
Const.FILTERS_POSITION_TOP,
|
||||||
|
Const.FILTERS_POSITION_INLINE,
|
||||||
|
Const.FILTERS_POSITION_BOTTOM
|
||||||
|
])
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Header;
|
export default Header;
|
||||||
|
|||||||
@ -729,7 +729,13 @@ describe('HeaderCell', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<HeaderCell column={ column } index={ index } onFilter={ onFilter } currFilters={ {} } />
|
<HeaderCell
|
||||||
|
column={ column }
|
||||||
|
index={ index }
|
||||||
|
onFilter={ onFilter }
|
||||||
|
currFilters={ {} }
|
||||||
|
filterPosition="inline"
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -767,7 +773,12 @@ describe('HeaderCell', () => {
|
|||||||
filterRenderer
|
filterRenderer
|
||||||
};
|
};
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<HeaderCell column={ column } index={ index } onExternalFilter={ onExternalFilter } />);
|
<HeaderCell
|
||||||
|
column={ column }
|
||||||
|
index={ index }
|
||||||
|
filterPosition="inline"
|
||||||
|
onExternalFilter={ onExternalFilter }
|
||||||
|
/>);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render successfully', () => {
|
it('should render successfully', () => {
|
||||||
|
|||||||
@ -1686,9 +1686,10 @@ class-utils@^0.3.5:
|
|||||||
isobject "^3.0.0"
|
isobject "^3.0.0"
|
||||||
static-extend "^0.1.1"
|
static-extend "^0.1.1"
|
||||||
|
|
||||||
classnames@2.2.5:
|
classnames@^2.2.5:
|
||||||
version "2.2.5"
|
version "2.2.6"
|
||||||
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.5.tgz#fb3801d453467649ef3603c7d61a02bd129bde6d"
|
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
|
||||||
|
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==
|
||||||
|
|
||||||
clean-css@4.1.9, clean-css@4.1.x:
|
clean-css@4.1.9, clean-css@4.1.x:
|
||||||
version "4.1.9"
|
version "4.1.9"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user