Add Excel/DataGrip-style distinct-value column filtering#318
Add Excel/DataGrip-style distinct-value column filtering#318wieslawsoltes wants to merge 4 commits into
Conversation
|
Self-review completed. I found and fixed descriptor restoration ambiguity for custom IFilteringModel implementations containing multiple descriptors with the same property path: exact column identity now takes precedence over property-path fallback. Commit 9dc052b adds regression coverage. Focused tests passed 6/6, the full unit suite passed 2,260/2,260, all six CI checks are successful, and git diff --check is clean. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9dc052ba34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3fba1aa44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Implements the Excel/DataGrip-style distinct-value column filter requested in #301.
The new
DataGridDistinctValueFilterFlyoutopens from the existing column-header filter button and provides:ListBoxwhose rows contain a checkbox, formatted value, and source-row count;FilteringOperator.Indescriptor updates when one or more values are checked;IDataGridColumnValueAccessor.Fixes #301.
Previous gap
ProDataGrid already had the pieces needed to apply an
Indescriptor and display an arbitrary per-columnFilterFlyout, but it did not provide a reusable distinct-value model or a built-in value/count/search presentation. Each application therefore had to enumerate values, keep checkbox state synchronized withFilteringModel, and build its own popup.Design
One filtering pipeline
DataGridDistinctValueFilterContextowns only popup state: distinct options, counts, search text, and checkbox selection. It does not introduce another filtering pipeline. Checkbox changes call the existing centralIFilteringModel.SetOrUpdate/RemoveAPIs, so header filtered state, selection preservation, adapter ownership, and collection-view refresh behavior remain unchanged.The generated descriptor uses:
ColumnKey/definition/column identity;FilteringOperator.In;When a custom
ValueCompareris supplied, the descriptor also carries a typed predicate so grouping and row-membership equality remain consistent.Reflection-free value access
The popup resolves values in this order:
DataGridDistinctValueFilterFlyout.ValueAccessor;DataGridColumnFilter.ValueAccessor;DataGridColumnDefinitionbinding.It deliberately does not reflect over the binding or
SortMemberPath. If no accessor is available, opening is canceled andLastErrorexplains the requirement. This keeps the feature trimming/AOT friendly and follows the repository's no-new-reflection rule.Counts and reopening
When the grid is backed by
IDataGridCollectionView, the popup enumeratesSourceCollection, not the currently filtered view. Reopening a filter therefore still shows every source value and its full count even when that same column currently filters the visible rows.Null values are grouped and displayed as
(Empty). Options are sorted using the current culture, case-insensitively.Search and selection semantics
Search only changes the visible
Optionscollection. It does not clear selections hidden by the current search. Rebuilding the list restores checked state from the activeIndescriptor without reapplying the filter.Theme and accessibility
Adds the compiled-binding
DataGridFilterDistinctValuesEditorTemplatetoThemes/Generic.xaml, with:DataGridFilterDistinctValuesEditorWidth;DataGridFilterDistinctValuesListMaxHeight;Sample and documentation
Tests
New model tests cover:
Indescriptor creation and removal;Headless integration tests cover:
Validation
dotnet test ... -f net10.0: 2,259 passed, 0 failednet8.0andnet10.0): 0 errorsnet10.0): 0 errorsgit diff --check: cleanBuilds retain the repository's existing warning baseline; this change adds no build errors.
Review hardening
Follow-up review preserves filter identity and state across ambiguous or changing data:
Current validation: 8/8 focused distinct-filter tests and 2,262/2,262 full unit tests pass. Review threads are resolved.