This section describes the behaviour of the Mini Filter and shows how it can be configured.
The Mini Filter allows the user to search for particular values in the Filter List. Entering text into the Mini Filter will narrow down the presented list of values shown inside the Set Filter, but by default will not filter the data inside the grid.
Keyboard Shortcuts Copy Link
When the ↵ Enter key is pressed while on the Mini Filter, the Set Filter will exclusively select all values in the Filter List that pass the Mini Filter and apply the filter immediately (note that even if an Apply Button is used, hitting ↵ Enter applies the filter).
Alternatively, you can choose to have the Mini Filter applied as the user is typing, i.e. as the Filter List is filtered, the Set Filter will be applied as described above so that the results in the grid will also be filtered at the same time. To enable this behaviour, use the following:
<ag-grid-vue
:columnDefs="columnDefs"
/* other grid options ... */>
</ag-grid-vue>
this.columnDefs = [
{
field: 'country',
filter: 'agSetColumnFilter',
filterParams: {
applyMiniFilterWhileTyping: true,
},
}
];The following example demonstrates this behaviour. Note the following:
- The Athlete column's Set Filter shows the Mini Filter with default behaviour. Try typing in the Mini Filter to search the Filter List, and then hit the ↵ Enter key and notice how the grid is filtered using the displayed values.
- The Country column's Set Filter applies the Mini Filter as you type because
filterParams.applyMiniFilterWhileTyping = true.
import {
createApp,
defineComponent,
onBeforeMount,
ref,
shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
ClientSideRowModelModule,
ColDef,
ColGroupDef,
GridApi,
GridOptions,
GridReadyEvent,
ISetFilterParams,
ModuleRegistry,
NumberFilterModule,
enableDevValidations,
} from "ag-grid-community";
import {
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
NumberFilterModule,
]);
const VueExample = defineComponent({
template: `
<div style="height: 100%">
<ag-grid-vue
style="width: 100%; height: 100%;"
@grid-ready="onGridReady"
:columnDefs="columnDefs"
:defaultColDef="defaultColDef"
:rowData="rowData"></ag-grid-vue>
</div>
`,
components: {
"ag-grid-vue": AgGridVue,
},
setup(props) {
const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
const columnDefs = ref<ColDef[]>([
// set filters
{ field: "athlete", filter: "agSetColumnFilter" },
{
field: "country",
filter: "agSetColumnFilter",
filterParams: {
applyMiniFilterWhileTyping: true,
} as ISetFilterParams,
},
// number filters
{ field: "gold", filter: "agNumberColumnFilter" },
{ field: "silver", filter: "agNumberColumnFilter" },
{ field: "bronze", filter: "agNumberColumnFilter" },
]);
const defaultColDef = ref<ColDef>({
flex: 1,
minWidth: 200,
floatingFilter: true,
});
const rowData = ref<IOlympicData[]>(null);
const onGridReady = (params: GridReadyEvent) => {
gridApi.value = params.api;
const updateData = (data) => (rowData.value = data);
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
.then((resp) => resp.json())
.then((data) => updateData(data));
};
return {
gridApi,
columnDefs,
defaultColDef,
rowData,
onGridReady,
};
},
});
const app = createApp(VueExample);
app.mount("#app");
Custom Searches Copy Link
Sometimes it is necessary to provide custom handling for Mini Filter searches, for example to substitute accented characters.
As with the Text Filter it is possible to supply a Text Formatter to the Set Filter which formats the text before applying the Mini Filter compare logic. The snippet below shows how this can be configured:
<ag-grid-vue
:columnDefs="columnDefs"
/* other grid options ... */>
</ag-grid-vue>
this.columnDefs = [
{
field: 'athlete',
filter: 'agSetColumnFilter',
filterParams: {
textFormatter: value => {
return value
.replace(/\s/g, '')
.replace(/[àáâãäå]/g, 'a')
.replace(/æ/g, 'ae')
.replace(/ç/g, 'c')
.replace(/[èéêë]/g, 'e')
.replace(/[ìíîï]/g, 'i')
.replace(/ñ/g, 'n')
.replace(/[òóôõö]/g, 'o')
.replace(/œ/g, 'oe')
.replace(/[ùúûü]/g, 'u')
.replace(/[ýÿ]/g, 'y')
.replace(/\W/g, '');
}
}
}
];The following example demonstrates searching when there are accented characters. Note the following:
- The Athlete column's Set filter is supplied a text formatter via
filterParams.textFormatterto ignore accents. - Searching using
'bjorn'will return all values containing'björn'.
The formatter is also passed the grid api and context as a second argument, along with the column and colDef it is working on. One callback set on defaultColDef.filterParams can therefore serve every column it applies to.
import {
createApp,
defineComponent,
onBeforeMount,
ref,
shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
ClientSideRowModelModule,
ColDef,
ColGroupDef,
GridApi,
GridOptions,
GridReadyEvent,
ISetFilterParams,
ModuleRegistry,
NumberFilterModule,
enableDevValidations,
} from "ag-grid-community";
import {
ColumnMenuModule,
ColumnsToolPanelModule,
ContextMenuModule,
SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ColumnsToolPanelModule,
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
NumberFilterModule,
]);
function replaceAccents(value: string) {
return value
.replace(new RegExp("[àáâãäå]", "g"), "a")
.replace(new RegExp("æ", "g"), "ae")
.replace(new RegExp("ç", "g"), "c")
.replace(new RegExp("[èéêë]", "g"), "e")
.replace(new RegExp("[ìíîï]", "g"), "i")
.replace(new RegExp("ñ", "g"), "n")
.replace(new RegExp("[òóôõøö]", "g"), "o")
.replace(new RegExp("œ", "g"), "oe")
.replace(new RegExp("[ùúûü]", "g"), "u")
.replace(new RegExp("[ýÿ]", "g"), "y")
.replace(new RegExp("\\W", "g"), "");
}
const filterParams: ISetFilterParams = {
textFormatter: replaceAccents,
};
const VueExample = defineComponent({
template: `
<div style="height: 100%">
<ag-grid-vue
style="width: 100%; height: 100%;"
@grid-ready="onGridReady"
:columnDefs="columnDefs"
:defaultColDef="defaultColDef"
:rowData="rowData"></ag-grid-vue>
</div>
`,
components: {
"ag-grid-vue": AgGridVue,
},
setup(props) {
const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
const columnDefs = ref<ColDef[]>([
// set filter
{
field: "athlete",
filter: "agSetColumnFilter",
filterParams: filterParams,
},
// number filters
{ field: "gold", filter: "agNumberColumnFilter" },
{ field: "silver", filter: "agNumberColumnFilter" },
{ field: "bronze", filter: "agNumberColumnFilter" },
]);
const defaultColDef = ref<ColDef>({
flex: 1,
minWidth: 200,
floatingFilter: true,
});
const rowData = ref<IOlympicData[]>(null);
const onGridReady = (params: GridReadyEvent) => {
gridApi.value = params.api;
const updateData = (data) => (rowData.value = data);
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
.then((resp) => resp.json())
.then((data) => updateData(data));
};
return {
gridApi,
columnDefs,
defaultColDef,
rowData,
onGridReady,
};
},
});
const app = createApp(VueExample);
app.mount("#app");
Enabling Case-Sensitive Searches Copy Link
By default the Mini Filter is case-insensitive. Practically this means that searching for bl would match Filter List values of Black, blue and BLONDE.
Case-sensitive searches can be enabled by using the caseSensitive filter parameter:
<ag-grid-vue
:columnDefs="columnDefs"
/* other grid options ... */>
</ag-grid-vue>
this.columnDefs = [
{
field: 'colour',
filter: 'agSetColumnFilter',
filterParams: {
caseSensitive: true
}
}
];The caseSensitive option also affects the values presented in the Filter List and API behaviours.
See Example: Filter List Case-Sensitivity for a demonstration of the change in behaviour.
Text Customisation Copy Link
Text used in the Mini Filter can be customised using Localisation.
The text shown as a placeholder in the Mini Filter textbox can be customised by setting 'searchOoo'.
When no matching values are found when typing in the Mini Filter, a message is displayed. This can be customised by setting 'noMatches'.
The example below shows this text being customised:
searchOoois set so that the Mini Filter textbox displays'Search values...'instead of the default text'Search...'noMatchesis set so that when no matches are found for the Mini Filter search, the message displays'No matches could be found.'instead of'No matches.'
import {
createApp,
defineComponent,
onBeforeMount,
ref,
shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
ClientSideRowModelModule,
ColDef,
ColGroupDef,
GridApi,
GridOptions,
GridReadyEvent,
LocaleModule,
LocaleText,
ModuleRegistry,
NumberFilterModule,
enableDevValidations,
} from "ag-grid-community";
import {
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
LocaleModule,
ClientSideRowModelModule,
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
NumberFilterModule,
]);
const VueExample = defineComponent({
template: `
<div style="height: 100%">
<ag-grid-vue
style="width: 100%; height: 100%;"
@grid-ready="onGridReady"
:columnDefs="columnDefs"
:defaultColDef="defaultColDef"
:localeText="localeText"
:rowData="rowData"></ag-grid-vue>
</div>
`,
components: {
"ag-grid-vue": AgGridVue,
},
setup(props) {
const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
const columnDefs = ref<ColDef[]>([
// set filters
{ field: "athlete", filter: "agSetColumnFilter" },
{ field: "country", filter: "agSetColumnFilter" },
// number filters
{ field: "gold", filter: "agNumberColumnFilter" },
{ field: "silver", filter: "agNumberColumnFilter" },
{ field: "bronze", filter: "agNumberColumnFilter" },
]);
const defaultColDef = ref<ColDef>({
flex: 1,
minWidth: 200,
floatingFilter: true,
});
const localeText = ref<LocaleText>({
searchOoo: "Search values...",
noMatches: "No matches could be found.",
});
const rowData = ref<IOlympicData[]>(null);
const onGridReady = (params: GridReadyEvent) => {
gridApi.value = params.api;
const updateData = (data) => (rowData.value = data);
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
.then((resp) => resp.json())
.then((data) => updateData(data));
};
return {
gridApi,
columnDefs,
defaultColDef,
localeText,
rowData,
onGridReady,
};
},
});
const app = createApp(VueExample);
app.mount("#app");
The Mini Filter input shares the grid-wide input behaviour (clear button, browser autocomplete) described in Input Fields.
Hiding the Mini Filter Copy Link
By default, the Mini Filter is shown whenever the Set Filter is used. If you would like to hide it, you can use the following:
<ag-grid-vue
:columnDefs="columnDefs"
/* other grid options ... */>
</ag-grid-vue>
this.columnDefs = [
{
field: 'country',
filter: 'agSetColumnFilter',
filterParams: {
suppressMiniFilter: true,
},
}
];The following example demonstrates hiding the mini filter. Note the following:
- The Athlete column's Set Filter shows the Mini Filter by default.
- The Country column's Set Filter does not have a Mini Filter as
filterParams.suppressMiniFilter = true.
import {
createApp,
defineComponent,
onBeforeMount,
ref,
shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
ClientSideRowModelModule,
ColDef,
ColGroupDef,
GridApi,
GridOptions,
GridReadyEvent,
ISetFilterParams,
ModuleRegistry,
NumberFilterModule,
enableDevValidations,
} from "ag-grid-community";
import {
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
// Enable extended validations only for development
enableDevValidations();
}
ModuleRegistry.registerModules([
ClientSideRowModelModule,
ColumnMenuModule,
ContextMenuModule,
SetFilterModule,
NumberFilterModule,
]);
const VueExample = defineComponent({
template: `
<div style="height: 100%">
<ag-grid-vue
style="width: 100%; height: 100%;"
@grid-ready="onGridReady"
:columnDefs="columnDefs"
:defaultColDef="defaultColDef"
:rowData="rowData"></ag-grid-vue>
</div>
`,
components: {
"ag-grid-vue": AgGridVue,
},
setup(props) {
const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
const columnDefs = ref<ColDef[]>([
// set filters
{ field: "athlete", filter: "agSetColumnFilter" },
{
field: "country",
filter: "agSetColumnFilter",
filterParams: {
suppressMiniFilter: true,
} as ISetFilterParams,
},
// number filters
{ field: "gold", filter: "agNumberColumnFilter" },
{ field: "silver", filter: "agNumberColumnFilter" },
{ field: "bronze", filter: "agNumberColumnFilter" },
]);
const defaultColDef = ref<ColDef>({
flex: 1,
minWidth: 200,
floatingFilter: true,
});
const rowData = ref<IOlympicData[]>(null);
const onGridReady = (params: GridReadyEvent) => {
gridApi.value = params.api;
const updateData = (data) => (rowData.value = data);
fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
.then((resp) => resp.json())
.then((data) => updateData(data));
};
return {
gridApi,
columnDefs,
defaultColDef,
rowData,
onGridReady,
};
},
});
const app = createApp(VueExample);
app.mount("#app");