mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
due to container will always set source data via store.setAllData so that handle the filtered data in the filter wrapper
This commit is contained in:
parent
79d5a51a39
commit
a2d082babf
@ -24,6 +24,7 @@ export default (Base, {
|
|||||||
componentWillReceiveProps({ isDataChanged, store, columns }) {
|
componentWillReceiveProps({ isDataChanged, store, columns }) {
|
||||||
// consider to use lodash.isEqual
|
// consider to use lodash.isEqual
|
||||||
if (JSON.stringify(this.state.currFilters) !== JSON.stringify(store.filters)) {
|
if (JSON.stringify(this.state.currFilters) !== JSON.stringify(store.filters)) {
|
||||||
|
store.filteredData = store.getAllData();
|
||||||
this.setState(() => ({ isDataChanged: true, currFilters: store.filters }));
|
this.setState(() => ({ isDataChanged: true, currFilters: store.filters }));
|
||||||
} else if (isDataChanged) {
|
} else if (isDataChanged) {
|
||||||
if (!(this.isRemoteFiltering() || this.isRemotePagination()) &&
|
if (!(this.isRemoteFiltering() || this.isRemotePagination()) &&
|
||||||
|
|||||||
@ -106,7 +106,7 @@ describe('Wrapper', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when props.isDataChanged is true and remote is enable', () => {
|
describe('when props.isDataChanged is true', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nextProps = createTableProps({ isDataChanged: true });
|
nextProps = createTableProps({ isDataChanged: true });
|
||||||
instance.componentWillReceiveProps(nextProps);
|
instance.componentWillReceiveProps(nextProps);
|
||||||
@ -118,13 +118,17 @@ describe('Wrapper', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when props.store.filters is different from current state.currFilters', () => {
|
describe('when props.store.filters is different from current state.currFilters', () => {
|
||||||
|
const nextData = [];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
nextProps = createTableProps();
|
nextProps = createTableProps();
|
||||||
nextProps.store.filters = { price: { filterVal: 20, filterType: FILTER_TYPE.TEXT } };
|
nextProps.store.filters = { price: { filterVal: 20, filterType: FILTER_TYPE.TEXT } };
|
||||||
|
nextProps.store.setAllData(nextData);
|
||||||
instance.componentWillReceiveProps(nextProps);
|
instance.componentWillReceiveProps(nextProps);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should setting states correctly', () => {
|
it('should setting states correctly', () => {
|
||||||
|
expect(nextProps.store.filteredData).toEqual(nextData);
|
||||||
expect(instance.state.isDataChanged).toBeTruthy();
|
expect(instance.state.isDataChanged).toBeTruthy();
|
||||||
expect(instance.state.currFilters).toBe(nextProps.store.filters);
|
expect(instance.state.currFilters).toBe(nextProps.store.filters);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user