From 8399dd0f7bed7c318d91ba346d67c4686ff8a59c Mon Sep 17 00:00:00 2001 From: Arthur Date: Tue, 21 Mar 2017 15:57:17 +0300 Subject: [PATCH] * #7. fix search filling with Worning --- src/components/Header.js | 15 ++++++++++++--- src/components/Main.js | 7 +++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/Header.js b/src/components/Header.js index 0c4da91..4941015 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -19,14 +19,23 @@ class Header extends React.Component { columns, data, sortId, - doDiscreteSearch + doDiscreteSearch, + columnsSearch } = this.props; if (this.isDiscreteSearch === true) { + let val = ''; + if (columnsSearch[data] !== CommonConstants.UNDEFINED) { + val = columnsSearch[data]; + } return (
- +
); } diff --git a/src/components/Main.js b/src/components/Main.js index 6183e14..7936a8c 100644 --- a/src/components/Main.js +++ b/src/components/Main.js @@ -464,8 +464,10 @@ class Main extends React.Component { var period = this.nowMillis - this.lastTimeKeyup; if (len > 0 || (len === 0 && val === '')) { // do search - this.setState({ - [name]: val + this.setState({columnsSearch: + Object.assign({}, this.state.columnsSearch, { + [name]: val + }) }); if (this.nothing === true && val === '') { return; // exit - user pressed not a symbol keys or teared down @@ -528,6 +530,7 @@ class Main extends React.Component { }; clonedOpts['columns'] = columns; clonedOpts['doDiscreteSearch'] = this.doDiscreteSearch.bind(this); + clonedOpts['columnsSearch'] = this.state.columnsSearch; if (this.sortableCols[data] === true) { clonedOpts['gteSort'] = CommonConstants.SORTABLE; if(typeof sortButtons[data] !== CommonConstants.UNDEFINED) {