Skip to content

feat(datagrid): filter a table by a cell's value from the cell context menu - #3101

Merged
datlechin merged 2 commits into
mainfrom
feat/filter-by-cell-value
Sep 23, 2026
Merged

datlechin merged 2 commits into
mainfrom
feat/filter-by-cell-value

Conversation

@datlechin

Copy link
Copy Markdown
Member

Fixes #3066

What it does

Right-click a cell in a table tab and open Filter. The submenu offers conditions built from that cell's stored value, and choosing one adds it to the filter bar and runs it against the whole table:

Cell Items
A value status = “paid”, status != “paid”, plus > and < on number and date columns
NULL status is NULL, status is not NULL
Empty text status is empty, status is not empty

The item sits just before Highlight, is built by CellFilterMenuBuilder behind a new DataGridViewDelegate.dataGridFilterMenuItem hook (nil by default, so only the data tab offers it), and follows the Highlight submenu's shape: one level, no key equivalents, titles cut to 32 characters on one line.

Before / After

A new submenu, so there is no before: the cell menu had no filter item at all. After, on an AlbumId cell of the Chinook sample, in light and dark:

Filter submenu on an AlbumId cell, light

Filter submenu on an AlbumId cell, dark

The same shots are in docs/images/cell-filter-menu*.png.

How it combines with filters already applied

The grid shows what it showed AND the new condition, the way Excel's "Filter by Selected Cell's Value", DBeaver and Console's add-to-search work. DataGrip replaces every filter instead, and its users have an open request (DBE-16840) asking for exactly this.

FilterCoordinator.cellFilterState does it in the filter bar's own terms so the bar stays truthful and the saved state restores the same set:

  • A row stays checked only if it is running, read from executedFilters rather than appliedFilters. Rows typed and never applied, and rows Clear left in the bar, resolve as applied under .all without having run, so they are unchecked, never deleted.
  • A row that already holds the condition is re-checked instead of repeated, and a condition the rows were already fetched with does nothing.
  • Under Match any with two or more running rows the condition cannot join them, so it runs alone; with one row or none the two modes agree and the mode becomes Match all.

It all runs inside the existing unsaved-edits guard. applyCommit and the new path now share one applyTransition, so state is written and re-queried in one guarded closure.

When there is no Filter item

The value goes into the same filter a reader could type, so the item is offered only where that filter matches the clicked row exactly:

  • query result tabs (no table to filter) and Redis (key-pattern search instead of the filter bar)
  • a new row or an edited cell (the server does not hold that value)
  • JSON, binary, spatial and array columns, and CLOB, NCLOB, NTEXT, LONG, XML and XMLTYPE columns, which have no = on their servers (ColumnTypeSQLQuoting.hasEqualityOperator)
  • a column whose type is not resolved, where the SQL generators guess at literals
  • text with a leading or trailing space (the generators trim it), the word NULL in a non-text column (rendered as IS NULL), and values over 10,000 characters

Also fixed

HighlightRuleDescription.truncated now turns line breaks into spaces when it cuts a value for a menu title. NSMenu lays a line break out as nothing, so a multi-line cell value ran its lines together in the existing Highlight submenu, and would have in the new one.

Known limits, shared with the filter bar

  • != leaves out rows where the column is NULL (SQL three-valued logic). The docs say so.
  • MongoDB dates lose their milliseconds in the grid (the plugin formats them with a plain ISO8601DateFormatter), so = on a date with milliseconds matches nothing. That is a MongoDB plugin fix of its own.
  • Equality on MySQL FLOAT columns is unreliable, as it is when typed into the filter bar.

Tests

  • CellFilterMenuBuilderTests (12): the value-to-condition mapping per value and column type, the round-trip exclusions, titles on one line, and the apply hand-off.
  • CellFilterStateTests (13): the transition from no filters, a running filter on another column and on the same column, rows left by Clear, a draft row, a soloed row stored unchecked, an edited running row, an identical row, Match any with one and with several rows, the find bar's OR search, and the saved state restoring the same rows.
  • CellFilterApplyTests (7): the data tab's menu item, choosing a condition re-queries with it, a second condition narrows the first, a declined discard guard changes nothing, query tabs and edited cells get no item, and the item sits just before Highlight.
  • ColumnTypeSQLQuotingTests and HighlightRuleDescriptionTests cover the new type rule and the title fix.
  • CellFilterMenuUITests: right-clicks an Album cell, opens Filter, picks the = item, and waits for the filter bar's Clear to enable.

Verified locally

  • Debug build passes.
  • 154 cases across the 13 suites that own the changed types pass (CellFilterMenuBuilderTests, CellFilterStateTests, CellFilterApplyTests, ColumnTypeSQLQuotingTests, HighlightRuleDescriptionTests, HighlightRuleSetTests, MainContentCoordinatorTabSwitchTests, FilterMoveTests, FilterRestoreTests, StructureRowMenuRouteTests, QuickHighlightOrderingTests, FilterPersistenceRoundTripTests, CoordinatorColumnVisibilityTests).
  • CellFilterMenuUITests passes. HighlightRulesUITests, which drives the same cell menu, passed its cell-menu case; testChangingARulesColumnKeepsTheColumnItWasGiven failed once inside the suite on a menu-item lookup in the rules popover and passed on its own. That popover is not touched here.
  • SwiftLint clean on every changed file; docs checks pass.
  • Reviewed by a separate code-review agent (Codex is out of credits until 2026-09-29). It found one real defect, a declined-discard test that never staged an edit and so could not reach the guard, which is fixed.

@mintlify

mintlify Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
TablePro 🟢 Ready View Preview Sep 23, 2026, 8:11 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@datlechin
datlechin merged commit 9fc22b3 into main Sep 23, 2026
5 checks passed
@datlechin
datlechin deleted the feat/filter-by-cell-value branch September 23, 2026 20:13

This branch was successfully deployed

1 active deployment
staging - docs — 6f2e6e68 Deployed Sep 23, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter by cell value

1 participant