Remove or clear search filter when applying external filter


  1.  Remove or clear search filter at the top right corner when applying external filter. I tried it using the following code. I was able to clear sorting and selection but not the search stuff on the top corner.I need to clear selection highlighted on green. Screenshot 2024-02-27 154931.png
  2. componentDidUpdate(prevProps, prevState) {
            if (this.state.grid) {
                if (!isEqual(this.props.refreshData , prevProps.refreshData)) {
                    this.state.grid.clearSelection();
                    this.state.grid.refresh();
                    this.state.grid.refreshColumns()
                    this.state.grid.clearSorting()
                    // this.state.grid.clearFilters();
                    // this.state.grid.refreshHeader();
                    //this.setState({grid: undefined})
                    this.setState({initialCollapseView: true})
                }
            }
        }

3 Replies

DM Dineshnarasimman Muthu Syncfusion Team February 29, 2024 01:47 AM UTC

Hi Viji Palanisamy,


Greetings from Syncfusion Support.


We have reviewed your query regarding clearing the search from the grid. We suggest you to use gridInstance.searchSettings.key as empty string(‘’) to clear the search from the grid. The code snippet of the implementation and sample have been attached for your reference.


  componentDidUpdate(prevprops) {

    if (this.gridInstance && prevprops) {

      this.gridInstance.searchSettings.key = ''; //empty string

    }

  }

 


Sample: https://stackblitz.com/edit/passing-props-to-child-component-in-react-1gkyxq?file=Grid.js,index.js


Please let us know if you need any further assistance.


Regards,

Dineshnarasimman M



VP Viji Palanisamy February 29, 2024 02:17 AM UTC

Thanks for you solution. It works Fine.



DM Dineshnarasimman Muthu Syncfusion Team February 29, 2024 04:33 AM UTC

Hi Viji Palanisamy,

 

Thanks for the update. We are glad that the solution met your requirement. Please get back to us for further assistance

 

Regards,

Dineshnarasimman M



Loader.
Up arrow icon