ag-grid

How can I set default value for a filter in Ag-Grid?


I want to set a Default value to a Column filter in Ag-Grid, which is active after initialization. How can I do that?


Solution

  • Looking at the example that is on the webpage under Filtering there is an input tag that is used filter with. The only change that you would need to make to this example would be to give the input an initial value with the value="" attribute.

    Alternatively, you can use the onGridReady attribute of the gridOptions that you have set up. This attribute expects a function callback. so do something like:

    var gridOptions{
        columnDefs: columnDefs,
        ...
        onGridReady: initialFilter,
    }
    
    function initialFilter(){
        gridOptions.api.setQuickFilter("initial filter value")
    }