We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to disable filter button on grid filter menu

Hi Team,

I am implementing grid menu filter https://ej2.syncfusion.com/angular/documentation/grid/filtering/filter-menu?cs-save-lang=1&cs-lang=ts


Here i need to disable filter button until unless user types sometin on serach input or search dropdown.



1 Reply

VB Vinitha Balasubramanian Syncfusion Team March 13, 2023 03:48 PM UTC

Hi Anshul,


Greetings from Syncfusion support.


Query: How to disable filter button on grid filter menu.


Based on your query, we understand that you want to disable the filter button until a user types something in the input field. Please refer the below code and sample for your reference.


[app.component.ts]

 

    actionComplete(args) {

        if (args.requestType == 'filterafteropen') {

            args.filterModel.dlgObj.btnObj[0].element.setAttribute('disabled', 'true')

            document.getElementsByClassName('e-flmenu-input')[0].addEventListener('input', (args) => {

                console.log(args.target['value']);

                if (args.target['value'] == "") {

                    this.grid.element.getElementsByClassName('e-flmenu-okbtn')[0].setAttribute('disabled', 'true');

                } else {

                    this.grid.element.getElementsByClassName('e-flmenu-okbtn')[0].removeAttribute('disabled');

                }

            })

        }

    }


Sample: https://stackblitz.com/edit/angular-fbxsmi-knwfyv?file=src%2Fapp.component.html


API: https://ej2.syncfusion.com/angular/documentation/api/grid/#actioncomplete


Regards,

Vinitha Balasubramanian


Loader.
Live Chat Icon For mobile
Up arrow icon