---
product: "AG Grid"
title: "Advanced Filter - Input & Builder"
description: "This section describes the grid options that configure the Advanced Filter input, where it is displayed, and the Advanced Filter Builder."
enterprise: true
framework: javascript
version: "36.3.0"
related:
    - title: "Columns & Filter Options"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/filter-advanced-columns/"
    - title: "Custom Filter Options"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/filter-advanced-custom-filter-options/"
    - title: "Filter Model / API"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/filter-advanced-api/"
llms: "https://www.ag-grid.com/archive/36.3.0/llms.txt"
---

# Advanced Filter - Input & Builder

This section describes the grid options that configure the Advanced Filter input, where it is displayed, and the Advanced Filter Builder.

## Advanced Filter Input

The buttons shown in the Advanced Filter input and the element it is displayed in can both be configured.

### Buttons

It is possible to customise the buttons displayed in the Advanced Filter, allowing for the use of other Filter Buttons such as Reset, Cancel and Clear. Configure via the grid option `advancedFilterParams` which follows the `IAdvancedFilterParams` interface:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `buttons` | `FilterAction[]` |  | `['apply']` | Specifies the buttons to be shown in the Advanced Filter, in the order they should be displayed in. The options are: `'apply'`: The Apply button will apply the filter. `'clear'`: The Clear button will clear the filter input without removing the current active filter. `'reset'`: The Reset button will clear the filter and apply an empty filter. `'cancel'`: The Cancel button will discard any changes that have been made to the filter in the UI, restoring the applied model. |
| `suppressBuilderButton` | `boolean` |  | `false` | Whether to hide the Builder button to open the Advanced Filter Builder |

The following example demonstrates configuring the Advanced Filter:

- The `Builder` button has been removed via `suppressBuilderButton`. The Builder can still be opened via the [API](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/filter-advanced-input-builder/#launch-via-api).
- The `buttons` have been configured to add the Clear and Reset buttons.

#### Configuring Advanced Filter

```ts
import {
  AdvancedFilterModel,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  GridStateModule,
  IAdvancedFilterParams,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  AdvancedFilterModule,
  ColumnMenuModule,
  ContextMenuModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

if (process.env.NODE_ENV !== "production") {
  // Enable extended validations only for development
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextFilterModule,
  NumberFilterModule,
  GridStateModule,
  AdvancedFilterModule,
  ClientSideRowModelModule,
  ColumnMenuModule,
  ContextMenuModule,
]);

const initialAdvancedFilterModel: AdvancedFilterModel = {
  filterType: "join",
  type: "AND",
  conditions: [
    {
      filterType: "join",
      type: "OR",
      conditions: [
        {
          filterType: "number",
          colId: "age",
          type: "greaterThan",
          filter: 23,
        },
        {
          filterType: "text",
          colId: "sport",
          type: "endsWith",
          filter: "ing",
        },
      ],
    },
    {
      filterType: "text",
      colId: "country",
      type: "contains",
      filter: "united",
    },
  ],
};

const advancedFilterParams: IAdvancedFilterParams = {
  buttons: ["clear", "apply", "reset"],
  suppressBuilderButton: true,
};

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "age", minWidth: 100 },
    { field: "gold", minWidth: 100 },
    { field: "silver", minWidth: 100 },
    { field: "bronze", minWidth: 100 },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 180,
    filter: true,
  },
  enableAdvancedFilter: true,
  initialState: {
    filter: {
      advancedFilterModel: initialAdvancedFilterModel,
    },
  },
  advancedFilterParams: advancedFilterParams,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: Configuring Advanced Filter](https://www.ag-grid.com/archive/36.3.0/examples/filter-advanced-input-builder/configuring-advanced-filter/typescript/)

### Filter Parent

By default the Advanced Filter is displayed underneath the Column Headers. To display the Advanced Filter outside of the grid (such as above it), set the grid option `advancedFilterParent`. The [Popup Parent](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/context-menu/#popup-parent) must also be set to an element that contains both the Advanced Filter parent and the grid.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `advancedFilterParent` | [`HTMLElement \| null`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) |  |  | DOM element to use as the parent for the Advanced Filter to allow it to appear outside of the grid. Set to `null` or `undefined` to appear inside the grid. [Module](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/modules/): `AdvancedFilterModule`. |

The following example demonstrates displaying the Advanced Filter outside of the grid:

- The Advanced Filter parent is set using an element directly above the grid.
- Popup Parent is set to the document body.

#### External Parent

```ts
import {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  AdvancedFilterModule,
  ColumnMenuModule,
  ContextMenuModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

if (process.env.NODE_ENV !== "production") {
  // Enable extended validations only for development
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextFilterModule,
  NumberFilterModule,
  AdvancedFilterModule,
  ClientSideRowModelModule,
  ColumnMenuModule,
  ContextMenuModule,
]);

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "age", minWidth: 100 },
    { field: "gold", minWidth: 100 },
    { field: "silver", minWidth: 100 },
    { field: "bronze", minWidth: 100 },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 180,
    filter: true,
  },
  enableAdvancedFilter: true,
  popupParent: document.body,
  onGridReady: (params: GridReadyEvent) => {
    // could also be provided via grid option `advancedFilterParent`
    params.api.setGridOption(
      "advancedFilterParent",
      document.getElementById("advancedFilterParent"),
    );
  },
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));
```

[Live example: External Parent](https://www.ag-grid.com/archive/36.3.0/examples/filter-advanced-input-builder/external-parent/typescript/)

## Advanced Filter Builder

The Advanced Filter Builder can be configured via the grid option `advancedFilterBuilderParams` which follows the `IAdvancedFilterBuilderParams` interface:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `addSelectWidth` | `number` |  | `120` | Width in pixels of the Advanced Filter Builder add button select popup. |
| `buttons` | `FilterAction[]` |  | `['apply', 'cancel']` | Specifies the buttons to be shown in the Advanced Filter Builder, in the order they should be displayed in. The options are: `'apply'`: The Apply button will apply the filter and close the builder. `'clear'`: The Clear button will clear the filter in the builder without removing the current active filter. `'reset'`: The Reset button will clear the filter and apply an empty filter. `'cancel'`: The Cancel button will discard any changes that have been made to the filter in the UI, and close the Builder without applying any changes. |
| `minWidth` | `number` |  | `500` | Minimum width in pixels of the Advanced Filter Builder popup. |
| `pillSelectMaxWidth` | `number` |  |  | Max width in pixels of the Advanced Filter Builder pill select popup. Unset, the popup grows to its widest option, bounded by the width of the Advanced Filter Builder. |
| `pillSelectMinWidth` | `number` |  | `140` | Min width in pixels of the Advanced Filter Builder pill select popup. |
| `showMoveButtons` | `boolean` |  | `false` | Whether to show the move up and move down buttons in the Advanced Filter Builder. |
| `suppressFullScreenButton` | `boolean` |  | `false` | Whether to hide the Full Screen button in the Advanced Filter Builder. |

### Launch via API

As well as using the button in the Advanced Filter, it's possible to launch the Advanced Filter Builder via the `showAdvancedFilterBuilder` grid API method, and hide it via `hideAdvancedFilterBuilder`:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `showAdvancedFilterBuilder` | `Function` |  |  | Open the Advanced Filter Builder dialog (if enabled). [Module](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/modules/): `AdvancedFilterModule`. |
| `hideAdvancedFilterBuilder` | `Function` |  |  | Closes the Advanced Filter Builder dialog (if enabled). Un-applied changes are discarded. [Module](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/modules/): `AdvancedFilterModule`. |

### Events

When the Advanced Filter Builder is shown or hidden, the `advancedFilterBuilderVisibleChanged` event is fired:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `advancedFilterBuilderVisibleChanged` | `AdvancedFilterBuilderVisibleChangedEvent` |  |  | Advanced Filter Builder visibility has changed (opened or closed). |

The following example demonstrates configuring the Advanced Filter Builder:

- The `Advanced Filter Builder` button displays the Advanced Filter Builder via the API method `showAdvancedFilterBuilder`.
- The `advancedFilterBuilderVisibleChanged` event is used to toggle the disabled status of the `Advanced Filter Builder` button.
- The `showMoveButtons` param is set in the `advancedFilterBuilderParams`, which displays buttons allowing the filter rows to be moved up and down (including via keyboard navigation).

#### Configuring Advanced Filter Builder

```ts
import {
  AdvancedFilterBuilderVisibleChangedEvent,
  AdvancedFilterModel,
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  GridReadyEvent,
  GridStateModule,
  IAdvancedFilterBuilderParams,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  AdvancedFilterModule,
  ColumnMenuModule,
  ContextMenuModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

if (process.env.NODE_ENV !== "production") {
  // Enable extended validations only for development
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextFilterModule,
  NumberFilterModule,
  GridStateModule,
  AdvancedFilterModule,
  ClientSideRowModelModule,
  ColumnMenuModule,
  ContextMenuModule,
]);

const initialAdvancedFilterModel: AdvancedFilterModel = {
  filterType: "join",
  type: "AND",
  conditions: [
    {
      filterType: "join",
      type: "OR",
      conditions: [
        {
          filterType: "number",
          colId: "age",
          type: "greaterThan",
          filter: 23,
        },
        {
          filterType: "text",
          colId: "sport",
          type: "endsWith",
          filter: "ing",
        },
      ],
    },
    {
      filterType: "text",
      colId: "country",
      type: "contains",
      filter: "united",
    },
  ],
};

const advancedFilterBuilderParams: IAdvancedFilterBuilderParams = {
  showMoveButtons: true,
  suppressFullScreenButton: true,
  buttons: ["clear", "apply", "cancel"],
};

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  columnDefs: [
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "age", minWidth: 100 },
    { field: "gold", minWidth: 100 },
    { field: "silver", minWidth: 100 },
    { field: "bronze", minWidth: 100 },
  ],
  defaultColDef: {
    flex: 1,
    minWidth: 180,
    filter: true,
  },
  enableAdvancedFilter: true,
  popupParent: document.getElementById("wrapper"),
  initialState: {
    filter: {
      advancedFilterModel: initialAdvancedFilterModel,
    },
  },
  advancedFilterBuilderParams: advancedFilterBuilderParams,
  onAdvancedFilterBuilderVisibleChanged: onAdvancedFilterBuilderVisibleChanged,
  onGridReady: (params: GridReadyEvent) => {
    // An external parent hides the input in the grid, so the filter is edited only via the Builder.
    params.api.setGridOption(
      "advancedFilterParent",
      document.getElementById("advancedFilterParent"),
    );
  },
  onFilterChanged: onFilterChanged,
};

function onAdvancedFilterBuilderVisibleChanged(
  event: AdvancedFilterBuilderVisibleChangedEvent<IOlympicData>,
) {
  const eButton = document.getElementById("advancedFilterBuilderButton")!;
  if (event.visible) {
    eButton.setAttribute("disabled", "");
  } else {
    eButton.removeAttribute("disabled");
  }
}

function onFilterChanged() {
  const advancedFilterApplied = !!gridApi!.getAdvancedFilterModel();
  document
    .getElementById("advancedFilterIcon")!
    .classList.toggle("filter-icon-disabled", !advancedFilterApplied);
}

function showBuilder() {
  gridApi!.showAdvancedFilterBuilder();
}

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data: IOlympicData[]) => gridApi!.setGridOption("rowData", data));

if (typeof window !== "undefined") {
  // Attach external event handlers to window so they can be called from index.html
  (<any>window).showBuilder = showBuilder;
}
```

[Live example: Configuring Advanced Filter Builder](https://www.ag-grid.com/archive/36.3.0/examples/filter-advanced-input-builder/configuring-advanced-filter-builder/typescript/)

## Localisation

If providing custom [Localisation](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/localisation/) values for the Advanced Filter, note that if the filter option values contain spaces, one option value cannot start with another option value.
