gp-grid-logo
Guides

Filtering

Add column filtering to the Vue 3 grid using built-in operators, custom filter components, and live updates as users refine their search criteria today.

gp-grid provides powerful column filtering.

Basic Filtering

Click the filter icon in a column header to open the filter popup:

<script setup lang="ts">
const columns: ColumnDefinition[] = [
  {
    field: "name",
    cellDataType: "text",
    width: 150,
    filterable: true,
  },
  {
    field: "salary",
    cellDataType: "number",
    width: 120,
    filterable: true,
  },
];
</script>

Filter Operators

Text Filters

OperatorDescription
containsValue contains text
notContainsValue does not contain text
equalsExact match
notEqualsNot an exact match
startsWithValue starts with text
endsWithValue ends with text
blankValue is empty
notBlankValue is not empty

Number Filters

OperatorDescription
=Equal to
!=Not equal to
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
betweenWithin range

Values Mode

Text filter popups also offer a checkbox list of the column's distinct values. Entries are grouped by display label: with a valueFormatter, several raw values can share one label, and ticking it selects all of them. The applied filter always stores the raw values (selectedValues: Set<CellValue>), so a formatter never changes what a server data source receives.

When the column contains blank cells (null, empty strings, or empty arrays such as a tags column with no tags), the list shows a (Blanks) entry. Untick it to exclude blank rows from the result.

Disable Filtering

<script setup lang="ts">
const columns: ColumnDefinition[] = [
  { field: "id", cellDataType: "number", width: 80, filterable: false },
  { field: "name", cellDataType: "text", width: 150 },  // filterable by default
];
</script>

Custom Filter Popup

Replace the content of the filter popup with your own UI through filterRenderer. A filter renderer is an object with two keys: content renders the popup body and clear decides the clear control. The example below keeps only a search box, Cancel and Apply:

SearchFilter.vue
<script setup lang="ts">
import { ref } from "vue";
import type { ColumnFilterModel, GridLabels } from "@gp-grid/vue";

const props = defineProps<{
  apply: (filter: ColumnFilterModel | null) => void;
  close: () => void;
  currentFilter?: ColumnFilterModel;
  labels: GridLabels;
}>();

const condition = props.currentFilter?.groups[0]?.conditions[0];
const text = ref(condition?.type === "text" ? condition.value ?? "" : "");

const applySearch = (): void => {
  if (text.value.trim() === "") {
    props.apply(null);
    return;
  }
  props.apply({
    groups: [{ conditions: [{ type: "text", operator: "contains", value: text.value }], combination: "and" }],
    combination: "and",
  });
};
</script>

<template>
  <div class="gp-grid-filter-content">
    <input
      v-model="text"
      class="gp-grid-filter-search"
      :placeholder="labels.searchPlaceholder"
      @keydown.enter="applySearch"
    />
    <div class="gp-grid-filter-buttons">
      <button type="button" @click="close">Cancel</button>
      <button type="button" class="gp-grid-filter-btn-apply" @click="applySearch">
        {{ labels.apply }}
      </button>
    </div>
  </div>
</template>

Set it on a column, or register it by key and reference the key:

<script setup lang="ts">
import type { ColumnDefinition, VueFilterRenderer } from "@gp-grid/vue";
import SearchFilter from "./SearchFilter.vue";

const searchFilter: VueFilterRenderer = { content: SearchFilter, clear: "default" }; 

const columns: ColumnDefinition[] = [
  { field: "bio", cellDataType: "text", width: 260, filterRenderer: searchFilter },
  { field: "status", cellDataType: "text", width: 120, filterRenderer: "search" },
];
</script>

<template>
  <GpGrid
    :columns="columns"
    :row-data="data"
    :row-height="36"
    :filter-renderers="{ search: searchFilter }"
  />
</template>

The filter-renderer prop sets a renderer for every filterable column. A column's own renderer wins, then the grid-wide one, then the built-in content. content and a custom clear can be render functions or components; a component receives the params as props.

Clear Control

clear is a required key, so removing the way to clear a filter is always a deliberate choice. Omitting it is a type error.

ValueResult
"default"The grid's Clear button, labelled with labels.clear
render function or component taking FilterClearParamsYour own control, rendered by the grid under the content
nullNo clear control

The clear control is placed inside .gp-grid-filter-clear, styled with :where so you can override it.

Filter Renderer Parameters

content receives FilterRendererParams:

PropertyTypeDescription
columnColumnDefinitionColumn definition
columnIdstringNormalized identity: colId ?? field
currentFilterColumnFilterModel | undefinedThe column's active filter
distinctValuesCellValue[]Distinct values; filled for text, boolean and object columns, empty otherwise
labelsGridLabelsResolved grid labels
apply(filter: ColumnFilterModel | null) => voidSet the filter (null clears it) and close the popup
close() => voidClose the popup without changing the filter

A custom clear control receives FilterClearParams:

PropertyTypeDescription
clear() => voidClear the column's filter and close the popup
hasFilterbooleanWhether the column has an active filter
labelsGridLabelsResolved grid labels

The grid keeps the popup's position, title, Escape and click-outside handling. The content is recreated when the popup moves to another column, so its local state starts fresh. Strings your content adds itself, such as "Cancel", are yours to localize: GridLabels only covers the grid's own controls. Types: VueFilterRenderer, VueFilterContentRenderer, VueFilterClearRenderer.

Grouped Conditions

The condition editor makes Boolean precedence explicit. Conditions live inside group cards: one AND/OR selector joins the conditions in a group, while a separate selector joins the groups themselves.

  • Use Add condition to extend the current group.
  • Use Add group to create a separate branch.
  • Empty conditions and groups are discarded when you apply the filter.

This means the popup can distinguish (A AND B) OR C from A AND (B OR C). The first expression is represented as:

import type { ColumnFilterModel } from "@gp-grid/vue";

const filter: ColumnFilterModel = {
  groups: [
    {
      conditions: [
        { type: "text", operator: "startsWith", value: "A" },
        { type: "text", operator: "endsWith", value: "z" },
      ],
      combination: "and",
    },
    {
      conditions: [
        { type: "text", operator: "equals", value: "Giovanni" },
      ],
      combination: "and",
    },
  ],
  combination: "or",
};

ColumnFilterModel.combination joins groups. Each FilterConditionGroup.combination joins the conditions inside that group. Filters belonging to different columns are combined with AND at row level.

Migrating Flat Condition Models

The underlying GridCore.setFilter() still accepts the previous flat model with conditions, combination, and optional per-condition nextOperator properties. It preserves the old left-to-right result and normalizes it into equivalent groups. The grid's filter state and server-side DataSourceRequest.filter always use the grouped shape.

Use normalizeColumnFilterModel(legacyFilter) when you want to migrate stored filter state explicitly.