# Manually Applying Column Filters

Canonical page: https://www.adaptabletools.com/docs/handbook-column-filter-manually-applying

- Column Filtering in AdapTable can be configured so that Filters are only applied when a button is clicked
- This is particularly useful if you wish to use the IN filter or you are using the server side row model

By default Column Filters are applied as soon as they are created or edited, so users can see the results immediately.

However sometimes this behaviour can be unwelcome.

This is often the case when [evaluating Column Filters on the Server](https://www.adaptabletools.com/docs/adaptable-server-evaluation/index.md), or the [In Filter](https://www.adaptabletools.com/docs/handbook-column-filter-in-filter/index.md) is being used

For this reason, AdapTable allows auto-evaluation of Column Filters to be turned off when necessary. 

This is done via the `manuallyApplyColumnFilter` property in [Column Filter Options](https://www.adaptabletools.com/docs/technical-reference-filter/index.md).

### `manuallyApplyColumnFilter`

Manually apply Column Filter only after a button is clicked

Set this property to *true* to stop AdapTable immediately evaluating Column Filter changes.

Instead an *Apply Filter* button will display in the Filter Form (and the Filter Bar will be disabled).

Only upon clicking this button, will the Column Filter be applied.

This property can be provided as a 'hard-coded' boolean value:

```ts {5}
// Don't apply Column Filters automatically but instead after a button is clicked
const adaptableOptions: AdaptableOptions = {
  filterOptions: {
    columnFilterOptions: {
      manuallyApplyColumnFilter: true,
    },
  },
};
``` 

Or via a boolean function which receives an [`AdaptableColumnContext`](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md) which simply contains the current Column: 

| Property | Type | Description |
| --- | --- | --- |
| [column](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#column) | [`AdaptableColumn`](https://www.adaptabletools.com/docs/reference/adaptablecolumn.md)`<TData>` | The current Column |
| [adaptableContext](https://www.adaptabletools.com/docs/reference/adaptablecolumncontext.md#adaptablecontext) | `any` | Custom application Context provided in `AdaptableOptions.adaptableContext` |

```ts {5}
// Don't apply Column Filters automatically for string columns
const adaptableOptions: AdaptableOptions = {
  filterOptions:{
    columnFilterOptions: {
      manuallyApplyColumnFilter: (context: AdaptableColumnContext) => {
        return context.column.dataType === 'text';
      },
    }
  }
};
```

In this scenario, AdapTable will not apply Column Filters immediately.

AdapTable will **disable the Filter Bar** for any Column where Manually-applying Filters is turned on

Instead 2 extra buttons are displayed in the Filter Form:

- `Apply` - only when that button is clicked are Column Filters evaluated and applied
- `Reset` - resets the Column Filters to what was previously applied (**not** the same as clearing)

**Example: Manually Apply Filters**

Manually Applying Column Filters

- In this example we set [manuallyApplyColumnFilter](https://www.adaptabletools.com/docs/technical-reference-filter/index.md) to *true* for String Columns
- As a result Column Filters in String Columns are not applied in the [Filter Form](https://www.adaptabletools.com/docs/handbook-column-filter-components/index.md) automatically - only when the `Apply Filter` button is clicked
- Additionally, the [Filter Bar](https://www.adaptabletools.com/docs/handbook-column-filter-components/index.md) is disabled for these Columns and the Filter Form opens instead

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts  [template]
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {
  AdaptableOptions,
  AdaptableColumnContext,
} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Manually Apply Filter',
  filterOptions: {
    columnFilterOptions: {
      manuallyApplyColumnFilter: (context: AdaptableColumnContext) => {
        return context.column.dataType === 'text';
      },
      defaultTextColumnFilter: 'IN',
    },
  },
  initialState: {
    Dashboard: {
      ModuleButtons: ['ColumnFilter'],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout', 'ColumnFilter'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'license',
            'has_projects',
            'has_pages',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'github_watchers',
            'week_issue_change',
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
