diff --git a/src/components/EnhancedTable.js b/src/components/EnhancedTable.js index 6a2c05f..bb3f6f7 100644 --- a/src/components/EnhancedTable.js +++ b/src/components/EnhancedTable.js @@ -148,6 +148,38 @@ class EnhancedTable extends Component { } // Update the search field as soon as the character is typed this.setState({searchQuery: query}); + + const searchQuery = query; + const searchColumns = this.state.searchColumns; + const data = this.props.data.filter((item) => { + let insert = false; + + // Iterate over the search column select boxes + searchColumns.map(column => { + try { + if( column.checked && (item[column.name] !== undefined) ) { + + if(item[column.name].hasOwnProperty('searchText') && item[column.name].searchText.toLowerCase().indexOf(searchQuery.toLowerCase().trim()) !== -1){ + insert = true; + } + else if(item[column.name].toLowerCase().indexOf(searchQuery.toLowerCase().trim()) !== -1){ + insert = true; + } + } + } + catch(error) { + //console.error(error); + } + return column; + }); + + if(insert){ + return item; + } + return false; + }); + + this.props.onSearchChange(data); }; /* @@ -198,6 +230,8 @@ class EnhancedTable extends Component { }); } + + return (