ProGridSign in

Features

Filtering

Filter from the column headers, from a bar, a rail or a dialog, or from a UI you build yourself. Every surface edits one model, so they cannot disagree.

Declaring a filter

Filtering follows from the column metadata rather than from a separate configuration. A column gets a filter by declaring type; the operators offered, the editor rendered, and how values are compared all follow from it. A column with notype has no filter, and filterable: false removes one from a column that declares a type for some other reason.

const columns: ProColumnDef<Order>[] = [
  // A column gets a filter by declaring what its values are.
  { accessorKey: "customer", header: "Customer", meta: { type: "string" } },
  { accessorKey: "units", header: "Units", meta: { type: "number" } },
  { accessorKey: "placed", header: "Placed", meta: { type: "date" } },

  // Options turn a string column into a checkbox list, and let the label the
  // reader sees differ from the code the API receives.
  {
    accessorKey: "status",
    header: "Status",
    meta: {
      type: "string",
      filterOptions: [{ value: "N", label: "New" }, "On track", "Delayed"],
    },
  },

  // Declares a type so the chart can read it, but is not filterable.
  { accessorKey: "score", header: "Score", meta: { type: "number", filterable: false } },
]

Where the filters live

The funnel in each column header is the baseline, and it is on by default. Thefilters prop adds a second, cross-column surface: a bar of chips above the body, a rail down the left, or a dialog. The toolbar grows a Filters button that toggles it and carries the active count, so a collapsed bar still says the rows are narrowed.

// The header funnels alone — the default.
<ProGrid columns={columns} data={orders} />

// A bar of chips above the body.
<ProGrid columns={columns} data={orders} filters />

// A rail down the left, listing every filterable column.
<ProGrid columns={columns} data={orders} filters={{ placement: "left", width: 280 }} />

// A dialog, opened from the toolbar's Filters button.
<ProGrid columns={columns} data={orders} filters={{ placement: "dialog" }} />

// One surface only: the panel, with the header funnels turned off.
<ProGrid
  columns={columns}
  data={orders}
  filters={{ placement: "left", headerFilters: false, quickFilter: true }}
/>

The surfaces do not replace the header funnels — both edit the same state and stay in step. Set headerFilters: false for a grid that should have exactly one place to filter.

Left on, the funnels can still be hidden at a glance: the toolbar’s settings menu carries a Header filters switch, and toolbar={{ headerFilters: true }} promotes it to a button of its own. It only reclaims the room — any filter already set stays set.

Live demo

One model, four surfaces

Switch the placement and filter from either surface — the header funnel and the panel are always showing the same thing.

import { useState } from "react"
import { ProGrid, type FilterConfig, type ProColumnDef } from "@/components/pro-grid"
import { formatCurrency, operationOrders, type OperationOrder } from "@/lib/operations-data"

function StatusCell({ value }: { value: unknown }) {
  const status = String(value)
  return <span className={`order-status order-status--${status.toLowerCase().replaceAll(" ", "-")}`}>{status}</span>
}

const baseColumns: ProColumnDef<OperationOrder>[] = [
  { accessorKey: "id", header: "Order", size: 118, meta: { label: "Order", type: "string" } },
  { accessorKey: "customer", header: "Customer", size: 190, meta: { label: "Customer", type: "string" } },
  {
    accessorKey: "region",
    header: "Region",
    size: 145,
    meta: {
      label: "Region",
      type: "string", filterVariant: "set",
      filterOptions: ["North America", "Europe", "Asia Pacific", "Latin America"],
      groupable: true,
      pivotable: true,
    },
  },
  {
    accessorKey: "status",
    header: "Status",
    size: 120,
    cell: ({ getValue }) => <StatusCell value={getValue()} />,
    meta: {
      label: "Status",
      type: "string", filterVariant: "set",
      filterOptions: ["On track", "At risk", "Delayed", "Complete"],
      groupable: true,
      pivotable: true,
    },
  },
  {
    accessorKey: "units",
    header: "Units",
    size: 88,
    meta: { label: "Units", type: "number", align: "right", aggregable: true, defaultAgg: "sum" },
  },
  {
    accessorKey: "revenue",
    header: "Revenue",
    size: 128,
    meta: {
      label: "Revenue",
      type: "number",
      align: "right",
      aggregable: true,
      defaultAgg: "sum",
      formatValue: (value) => formatCurrency(Number(value)),
    },
  },
]

const filterDemoRows = operationOrders.slice(0, 40)

const FILTER_PLACEMENTS = ["top", "left", "dialog", "none"] as const

export function FilteringDocsDemo() {
  const [placement, setPlacement] =
    useState<NonNullable<FilterConfig["placement"]>>("top")
  const [headerFilters, setHeaderFilters] = useState(true)

  return (
    <div className="space-y-3">
      <div className="flex flex-wrap items-center gap-3 text-sm">
        <span className="text-muted-foreground">Placement</span>
        <div className="flex overflow-hidden rounded-md border border-border">
          {FILTER_PLACEMENTS.map((p) => (
            <button
              key={p}
              onClick={() => setPlacement(p)}
              aria-pressed={placement === p}
              className={`px-3 py-1 text-xs capitalize ${
                placement === p ? "bg-primary text-primary-foreground" : "hover:bg-muted"
              }`}
            >
              {p}
            </button>
          ))}
        </div>
        <label className="flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground">
          <input
            type="checkbox"
            checked={headerFilters}
            onChange={(e) => setHeaderFilters(e.target.checked)}
          />
          Header funnels
        </label>
      </div>

      <ProGrid<OperationOrder>
        columns={baseColumns}
        data={filterDemoRows}
        getRowId={(row) => row.id}
        height={340}
        title="Orders"
        filters={{ placement, headerFilters }}
      />
    </div>
  )
}
Placement

Orders

FiltersNo filters yet — add one →
Order
Customer
Region
Status
Units
Revenue
Total
Sum8580
Sum$1,742,820
40 rows

A filter UI of your own

When the filters belong to your page rather than to the grid — a search header, a sidebar that also holds unrelated controls — useGridFilters gives you the model without the markup. It owns the two state slices, resolves every filterable column into a field you can render however you like, and hands back the functions to change them: setQuickFilter, setOperator, setValue,clear and reset, plus inputProps for binding a plain input.

const filters = useGridFilters({ columns })

// `filters.fields` is one resolved entry per filterable column: its label, its
// type, the operators it may use, and its options. Nothing reaches into the grid.
return (
  <>
    <input value={filters.quickFilter} onChange={(e) => filters.setQuickFilter(e.target.value)} />

    {filters.fields.map((field) => (
      <label key={field.id}>
        {field.label}
        <select
          value={field.condition.operator}
          onChange={(e) => filters.setOperator(field.id, e.target.value)}
        >
          {field.operators.map((op) => <option key={op} value={op}>{op}</option>)}
        </select>
        <input {...filters.inputProps(field.id)} />
      </label>
    ))}

    <button onClick={filters.reset}>Reset ({filters.activeCount})</button>

    <ProGrid columns={columns} data={orders} {...filters.gridProps} />
  </>
)
Live demo

Filters outside the grid

The grid mounts no filter surface here. Everything above it is ordinary markup driven by the controller.

import { ProGrid, gridMessages, operatorLabel, useGridFilters, type FilterOperator, type ProColumnDef } from "@/components/pro-grid"
import { formatCurrency, operationOrders, type OperationOrder } from "@/lib/operations-data"

function StatusCell({ value }: { value: unknown }) {
  const status = String(value)
  return <span className={`order-status order-status--${status.toLowerCase().replaceAll(" ", "-")}`}>{status}</span>
}

const baseColumns: ProColumnDef<OperationOrder>[] = [
  { accessorKey: "id", header: "Order", size: 118, meta: { label: "Order", type: "string" } },
  { accessorKey: "customer", header: "Customer", size: 190, meta: { label: "Customer", type: "string" } },
  {
    accessorKey: "region",
    header: "Region",
    size: 145,
    meta: {
      label: "Region",
      type: "string", filterVariant: "set",
      filterOptions: ["North America", "Europe", "Asia Pacific", "Latin America"],
      groupable: true,
      pivotable: true,
    },
  },
  {
    accessorKey: "status",
    header: "Status",
    size: 120,
    cell: ({ getValue }) => <StatusCell value={getValue()} />,
    meta: {
      label: "Status",
      type: "string", filterVariant: "set",
      filterOptions: ["On track", "At risk", "Delayed", "Complete"],
      groupable: true,
      pivotable: true,
    },
  },
  {
    accessorKey: "units",
    header: "Units",
    size: 88,
    meta: { label: "Units", type: "number", align: "right", aggregable: true, defaultAgg: "sum" },
  },
  {
    accessorKey: "revenue",
    header: "Revenue",
    size: 128,
    meta: {
      label: "Revenue",
      type: "number",
      align: "right",
      aggregable: true,
      defaultAgg: "sum",
      formatValue: (value) => formatCurrency(Number(value)),
    },
  },
]

const filterDemoRows = operationOrders.slice(0, 40)

export function HeadlessFiltersDocsDemo() {
  // The grid mounts no filter surface at all; this UI is the only one, and it is
  // ordinary markup driven by the controller's own functions.
  const filters = useGridFilters({ columns: baseColumns })

  return (
    <div className="space-y-3">
      <div className="flex flex-wrap items-end gap-3 rounded-lg border border-border bg-muted/30 p-3">
        <label className="flex flex-col gap-1 text-xs">
          <span className="text-muted-foreground">Search</span>
          <input
            className="h-8 w-44 rounded-md border border-input bg-background px-2 text-sm"
            placeholder="Search every column…"
            value={filters.quickFilter}
            onChange={(e) => filters.setQuickFilter(e.target.value)}
          />
        </label>

        {filters.fields
          .filter((f) => f.id === "region" || f.id === "units")
          .map((field) => (
            <label key={field.id} className="flex flex-col gap-1 text-xs">
              <span className="text-muted-foreground">{field.label}</span>
              <div className="flex gap-1">
                <select
                  className="h-8 rounded-md border border-input bg-background px-1 text-xs"
                  value={field.condition.operator}
                  onChange={(e) => filters.setOperator(field.id, e.target.value as FilterOperator)}
                >
                  {field.operators.map((op) => (
                    <option key={op} value={op}>
                      {operatorLabel(gridMessages("en"), field.type, op)}
                    </option>
                  ))}
                </select>
                <input
                  className="h-8 w-28 rounded-md border border-input bg-background px-2 text-sm"
                  {...filters.inputProps(field.id)}
                />
              </div>
            </label>
          ))}

        <button
          className="h-8 rounded-md border border-border px-3 text-xs hover:bg-muted"
          onClick={filters.reset}
        >
          Reset ({filters.activeCount})
        </button>
      </div>

      <ProGrid<OperationOrder>
        columns={baseColumns}
        data={filterDemoRows}
        getRowId={(row) => row.id}
        height={300}
        toolbar={false}
        {...filters.gridProps}
      />
    </div>
  )
}
Order
Customer
Region
Status
Units
Revenue
Total
Sum8580
Sum$1,742,820
40 rows

Server mode

When an API owns paging, the filter model is handed to your data source instead of being evaluated in the browser — the same objects, so the semantics do not change with the mode. Two rules apply to every surface: the join is forced to AND, since a flat filter list cannot express OR, and the operator menu is narrowed to what your dialect declares. Pass serverOperators a list to narrow it exactly.

A set column derives its choices from the loaded rows, which is only the current page once an API pages — so declare filterOptions for those columns. The same applies outside the grid, where there are no rows at all.

From the handle

Filters and the quick filter are both on the grid handle, and both are part ofProGridState, so a saved view restores them alongside the layout.

gridRef.current.setFilters([
  { id: "region", type: "string", conditions: [{ operator: "in", value: ["Europe"] }], join: "AND" },
])
gridRef.current.setQuickFilter("acme")
gridRef.current.clearFilters()  // filters and search; the sort stays