diff --git a/src/components/EnhancedTable.js b/src/components/EnhancedTable.js index 56f7cb8..c2eb106 100644 --- a/src/components/EnhancedTable.js +++ b/src/components/EnhancedTable.js @@ -93,8 +93,26 @@ class EnhancedTable extends Component { const data = order === 'desc' - ? this.state.data.sort((a, b) => (b[orderBy].toLowerCase() < a[orderBy].toLowerCase() ? -1 : 1)) - : this.state.data.sort((a, b) => (a[orderBy].toLowerCase() < b[orderBy].toLowerCase() ? -1 : 1)); + ? this.state.data.sort((a, b) => { + console.log(a[orderBy]); + console.log(b[orderBy]); + if(a[orderBy].hasOwnProperty('searchText')){ + a[orderBy] = a[orderBy].searchText; + } + if(b[orderBy].hasOwnProperty('searchText')){ + b[orderBy] = b[orderBy].searchText; + } + return b[orderBy].toLowerCase() < a[orderBy].toLowerCase() ? -1 : 1; + }) + : this.state.data.sort((a, b) => { + if(a[orderBy].hasOwnProperty('searchText')){ + a[orderBy] = a[orderBy].searchText; + } + if(b[orderBy].hasOwnProperty('searchText')){ + b[orderBy] = b[orderBy].searchText; + } + return (a[orderBy].toLowerCase() < b[orderBy].toLowerCase() ? -1 : 1); + }); this.setState({ data, order, orderBy }); };