ProGridSign in

Features

Column types

A column declares what its values are. Everything downstream — the operators offered, the editor rendered, how those operators are worded, and how values compare — follows from that one declaration.

Declare the type

Setting meta.type is what gives a column a filter. There is nothing else to wire up: the operator menu, the value editor, and the comparison are all attributed from it.

const columns: ProColumnDef<Order>[] = [
  { accessorKey: "customer",  header: "Customer",  meta: { type: "string" } },
  { accessorKey: "revenue",   header: "Revenue",   meta: { type: "number" } },
  { accessorKey: "updatedAt", header: "Updated",   meta: { type: "date" } },
  { accessorKey: "expedited", header: "Expedited", meta: { type: "boolean" } },
  { accessorKey: "tags",      header: "Tags",      meta: { type: "array" } },
]
TypeHoldsAcceptsEditor
stringText"Northstar Health"Text box, or a checkbox list once there are options
numberNumeric1250, "1250"Number box; two of them for a range
dateA moment in time"2024-01-15", Date, epoch msDate picker
booleanTrue or falsetrue, "true", 1True/False select
arrayA list, per cell["urgent", "billing"]Checkbox list of the distinct members
Live demo

One column per type

Open each header filter: a calendar-aware date, a true/false toggle, a multi-value tag list, and a numeric range.

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

/**
 * One column per primitive, so every editor and comparison is reachable.
 *
 * The boolean and array columns are derived rather than stored: the demo dataset
 * has no such fields, and `accessorFn` is how a real projection would surface
 * them anyway.
 */
const typedColumns: ProColumnDef<OperationOrder>[] = [
  { accessorKey: "id", header: "Order", size: 110, meta: { label: "Order", type: "string" } },
  {
    accessorKey: "updatedAt",
    header: "Updated",
    size: 130,
    meta: {
      label: "Updated",
      type: "date",
      formatValue: (value) => new Date(String(value)).toLocaleDateString(),
    },
  },
  {
    id: "expedited",
    accessorFn: (row) => row.priority === "Critical",
    header: "Expedited",
    size: 110,
    cell: ({ getValue }) => (getValue() ? "Yes" : "No"),
    meta: { label: "Expedited", type: "boolean" },
  },
  {
    id: "tags",
    accessorFn: (row) => [row.channel, row.priority],
    header: "Tags",
    size: 190,
    cell: ({ getValue }) => (getValue() as string[]).join(", "),
    meta: { label: "Tags", type: "array" },
  },
  {
    accessorKey: "revenue",
    header: "Revenue",
    size: 128,
    meta: {
      label: "Revenue",
      type: "number",
      align: "right",
      formatValue: (value) => formatCurrency(Number(value)),
    },
  },
]

const basicDemoRows = operationOrders.slice(0, 18)

export function ColumnTypesDocsDemo() {
  return (
    <ProGrid<OperationOrder>
      columns={typedColumns}
      data={basicDemoRows}
      getRowId={(row) => row.id}
      height={330}
      title="One column per type"
      toolbar={{ pivot: false, chart: false, refresh: false }}
    />
  )
}

One column per type

Order
Updated
Expedited
Tags
Revenue
18 rows

Operators by type

Types share an operator wherever the underlying question is the same and only the comparison differs, so the wording changes rather than the operator. On a date, gt reads After; on an array, in reads Has any of. Translations follow the same rule.

TypeOperators, in menu order
stringContainscontainsDoes not containnotContainsEqualsequalsDoes not equalnotEqualsStarts withstartsWithEnds withendsWithIs any ofinIs none ofnotInIs blankblankIs not blanknotBlank
numberEqualsequalsDoes not equalnotEqualsGreater thangtGreater than or equalgteLess thanltLess than or equallteBetweeninRangeIs any ofinIs none ofnotInIs blankblankIs not blanknotBlank
dateOnequalsNot onnotEqualsAftergtOn or aftergteBeforeltOn or beforelteBetweeninRangeIn the lastinLastIn the nextinNextIs emptyblankIs not emptynotBlank
booleanIsequalsIs blankblankIs not blanknotBlank
arrayHas any ofinHas none ofnotInHas all ofhasAllIs emptyblankIs not emptynotBlank

Dates compare as calendar days

By default a date filter asks a calendar question in the reader’s own timezone, so On the 15th matches every row stamped that day whatever the time it carries. Values are read from ISO strings, Date objects, or epoch milliseconds.

// "On the 15th" matches every row stamped that day, whatever the time.
{ accessorKey: "updatedAt", header: "Updated", meta: { type: "date" } }

// Compare exact timestamps instead, for a column where the clock matters.
{
  accessorKey: "startedAt",
  header: "Started",
  meta: { type: "date", dateGranularity: "instant" },
}

Dates also get two operators absolute dates cannot express: inLast and inNext take a day count and resolve against the day the filter runs, so a saved view reading “in the last 7 days” stays current.

Booleans and arrays

A boolean filter is a single True/False choice. Because APIs spell booleans variously, the comparison accepts true, "true", 1 and "1" — and their false counterparts. A cell that is none of those matches neither choice rather than silently counting as false.

// The cell itself holds a list.
{ accessorKey: "tags", header: "Tags", meta: { type: "array" } }
// row.tags === ["urgent", "billing"]

An array column filters on membership. Its checkbox list shows the distinct members found across the rows rather than whole tuples, and an empty array counts as blank.

  • Has any of keeps rows sharing at least one selected member.
  • Has none of keeps rows sharing none of them.
  • Has all of requires every selected member to be present.

Overriding the editor, and opting out

The editor follows from the type, so filterVariant is rarely needed. The one common case is a string column whose choices are discovered from the loaded rows instead of declared up front.

// A string column whose choices come from the loaded rows rather than
// from a declared list — the only common reason to override the editor.
{ accessorKey: "region", header: "Region", meta: { type: "string", filterVariant: "set" } }

// Declared options already imply the list editor, so no override is needed.
{
  accessorKey: "status",
  header: "Status",
  meta: { type: "string", filterOptions: ["New", "Processing", "Complete"] },
}

Because declaring a type attributes a filter, a column typed only so the chart or an aggregation reads it correctly needs to say so explicitly.

// Charted and aggregated, but never filtered.
{
  accessorKey: "score",
  header: "Score",
  meta: { type: "number", filterable: false, aggregable: true, defaultAgg: "avg" },
}