mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
parent
49f866a8ff
commit
0ff91b4135
@ -248,20 +248,27 @@ export default class Table extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleFilter = (column, nextFilters) => {
|
handleFilter = (column, nextFilters) => {
|
||||||
|
const props = this.props;
|
||||||
|
let pagination = { ...this.state.pagination };
|
||||||
const filters = {
|
const filters = {
|
||||||
...this.state.filters,
|
...this.state.filters,
|
||||||
[this.getColumnKey(column)]: nextFilters,
|
[this.getColumnKey(column)]: nextFilters,
|
||||||
};
|
};
|
||||||
// Remove filters not in current columns
|
// Remove filters not in current columns
|
||||||
const currentColumnKeys = this.props.columns.map(c => this.getColumnKey(c));
|
const currentColumnKeys = props.columns.map(c => this.getColumnKey(c));
|
||||||
Object.keys(filters).forEach((columnKey) => {
|
Object.keys(filters).forEach((columnKey) => {
|
||||||
if (currentColumnKeys.indexOf(columnKey) < 0) {
|
if (currentColumnKeys.indexOf(columnKey) < 0) {
|
||||||
delete filters[columnKey];
|
delete filters[columnKey];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reset current prop
|
||||||
|
pagination.current = 1;
|
||||||
|
pagination.onChange(pagination.current);
|
||||||
|
|
||||||
const newState = {
|
const newState = {
|
||||||
selectionDirty: false,
|
selectionDirty: false,
|
||||||
|
pagination,
|
||||||
};
|
};
|
||||||
const filtersToSetState = { ...filters };
|
const filtersToSetState = { ...filters };
|
||||||
// Remove filters which is controlled
|
// Remove filters which is controlled
|
||||||
@ -274,9 +281,21 @@ export default class Table extends React.Component {
|
|||||||
if (Object.keys(filtersToSetState).length > 0) {
|
if (Object.keys(filtersToSetState).length > 0) {
|
||||||
newState.filters = filtersToSetState;
|
newState.filters = filtersToSetState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Controlled current prop will not respond user interaction
|
||||||
|
if (props.pagination && 'current' in props.pagination) {
|
||||||
|
newState.pagination = {
|
||||||
|
...pagination,
|
||||||
|
current: this.state.pagination.current,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
this.setState(newState, () => {
|
this.setState(newState, () => {
|
||||||
this.props.onChange(...this.prepareParamsArguments({
|
props.onChange(...this.prepareParamsArguments({
|
||||||
...this.state, selectionDirty: false, filters,
|
...this.state,
|
||||||
|
selectionDirty: false,
|
||||||
|
filters,
|
||||||
|
pagination,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user