# Floating filters (per-operator)

The inline filter row honours every operator per column: pick the operator from the cell funnel, the value input switches to the column type (number / date / text), and Between shows a second "To" input inline - no full menu needed.

Uses `@svgrid/grid` (MIT). Category: Filtering & Search. Live demo: https://svgrid.com/demos/179-floating-filters/

Install: `npm i @svgrid/grid` (Svelte 5).

## About this example

The inline filter row of the Svelte 5 data grid with every operator per column. Click the funnel in a filter cell to pick the operator, the value input switches to the column's type for number, date or text, and Between shows a second To input right in the row, so common filters never need the full column menu. It takes filterMode='row' and about fifty lines.

The floating filter row under the headers now honours EVERY operator per column: click the funnel in a cell to pick the operator, the value input switches to the column's type (number / date / text), and `between` shows a second "To" input right inline. No need to open the full menu.

## Imports, features and API used

- Imports: `@svgrid/grid`, `../shared/seed`
- Table features registered: `rowSortingFeature`, `columnFilteringFeature`
- Columns: `firstName` (First name), `lastName` (Last name), `department` (Department), `age` (Age), `salary` (Salary), `joinedAt` (Joined)

## Frequently asked questions

### How do I show a filter row under the headers?

Set filterMode='row' with columnFilteringFeature registered. Each column gets an input typed by its editorType; number and date columns get the matching input types.

### Can I change the operator without opening the menu?

Yes. The funnel icon in each filter cell opens a small operator list; Between adds a To input inline.

### Does the row support dates?

Yes. A column with editorType 'date' renders a date input in the row, and Between takes two dates.

## Related documentation

- [Floating filters](https://svgrid.com/docs/help/filtering/floating-filters.md)

## Related articles

- [Excel-Style Filtering for Your Svelte Data Grid](https://svgrid.com/blog/excel-style-filtering/) - Per-column filter menus, a filter row, global search, and server-side filtering - all wired through a single columnFilteringFeature in SvGrid.
- [How We Built Excel-Style Filters](https://svgrid.com/blog/how-we-built-excel-style-filters/) - How SvGrid implements per-column filter menus, type-aware operators, and a shared filter model that works identically for in-memory and server-side data.
- [Set Filters and Custom Filter Logic in SvGrid](https://svgrid.com/blog/custom-set-filters/) - Build Excel-style checkbox set filters with live facet counts and a custom numeric range filter - using four API calls and plain Svelte markup.

## Source code (179-floating-filters.svelte)

```svelte
<!-- Documented in: docs/help/filtering/floating-filters.md -->
<script lang="ts">
  /**
   * 179. Floating filters - per-operator inline filter row
   * ------------------------------------------------------
   * The floating filter row under the headers now honours EVERY operator per
   * column: click the funnel in a cell to pick the operator, the value input
   * switches to the column's type (number / date / text), and `between` shows
   * a second "To" input right inline. No need to open the full menu.
   */
  import {
    SvGrid,
    tableFeatures,
    rowSortingFeature,
    columnFilteringFeature,
    type GridColumns,
  } from '@svgrid/grid'
  import { makePeople, type Person } from '../shared/seed'

  const features = tableFeatures({ rowSortingFeature, columnFilteringFeature })
  let rows = $state<Person[]>(makePeople(120))

  const columns: GridColumns<Person> = [
    { field: 'firstName', header: 'First name', editorType: 'text', width: 140 },
    { field: 'lastName', header: 'Last name', editorType: 'text', width: 140 },
    { field: 'department', header: 'Department', editorType: 'text', width: 150 },
    { field: 'age', header: 'Age', editorType: 'number', width: 120, align: 'right' },
    { field: 'salary', header: 'Salary', editorType: 'number', width: 150, align: 'right',
      format: { type: 'currency', currency: 'USD', options: { maximumFractionDigits: 0 } } },
    { field: 'joinedAt', header: 'Joined', editorType: 'date', width: 160, format: { type: 'date', pattern: 'y-m-d' } },
  ]
</script>

<section class="flex flex-col flex-1 min-h-0 gap-3">
  <p class="text-sm shrink-0" style="color: var(--sg-fg);">
    Type straight into the <strong>filter row</strong> under the headers. Click a
    cell's <strong>funnel</strong> to switch operators - <code>Age</code> to
    <em>Between</em> gets two number inputs (From / To); <code>Joined</code> uses a
    real date picker; <code>Salary</code> takes <em>Greater than</em>. Per-operator,
    per-type, all inline.
  </p>

  <div class="flex-1 min-h-0">
    <SvGrid responsive={true}
      columnResize
      data={rows}
      columns={columns}
      features={features}
      filterMode="row"
      showRowNumbers={true}
      rowHeight={36}
      containerHeight="100%"
      fitColumns={true}
    />
  </div>
</section>
```

[View this example on GitHub](https://github.com/sv-grid/sv-grid/blob/main/examples/src/demos/179-floating-filters.svelte)
