diff --git a/packages/datalib/src/GridDisplay.ts b/packages/datalib/src/GridDisplay.ts index 5f30ce98..626499ba 100644 --- a/packages/datalib/src/GridDisplay.ts +++ b/packages/datalib/src/GridDisplay.ts @@ -338,4 +338,16 @@ export abstract class GridDisplay { }); this.reload(); } + + get filterCount() { + return _.compact(_.values(this.config.filters)).length; + } + + clearFilters() { + this.setConfig({ + ...this.config, + filters: {}, + }); + this.reload(); + } } diff --git a/packages/web/src/datagrid/DataFilterControl.js b/packages/web/src/datagrid/DataFilterControl.js index 2d2a24d9..1ad2fb71 100644 --- a/packages/web/src/datagrid/DataFilterControl.js +++ b/packages/web/src/datagrid/DataFilterControl.js @@ -207,7 +207,8 @@ export default function DataFilterControl({ isReadOnly = false, filterType, filt React.useEffect(() => { editorRef.current.value = filter || ''; - }, []); + updateFilterState(); + }, [filter]); const handleShowMenu = () => { const rect = buttonRef.current.getBoundingClientRect(); diff --git a/packages/web/src/datagrid/DataGridCore.js b/packages/web/src/datagrid/DataGridCore.js index 75be9449..95bccf70 100644 --- a/packages/web/src/datagrid/DataGridCore.js +++ b/packages/web/src/datagrid/DataGridCore.js @@ -312,12 +312,20 @@ export default function DataGridCore(props) { }); } + const hederColwidthPx = '40px'; + const filterCount = display.filterCount; + + const handleClearFilters = () => { + display.clearFilters(); + }; + // console.log('visibleRealColumnIndexes', visibleRealColumnIndexes); return ( + {realColumns.map(col => ( + + {filterCount > 0 && ( + + )} + {realColumns.map(col => ( ( + {firstVisibleRowScrollIndex + index + 1} {realColumns.map(col => (