Support server-side pagination in SfDataGrid column filters#2544
Support server-side pagination in SfDataGrid column filters#2544ariefwijaya wants to merge 1 commit into
Conversation
Adds five related improvements so SfDataGrid's built-in filters work correctly when rows are paged from a server: - CheckboxFilterValueProvider mixin: a DataGridSource can supply a static list of checkbox-filter values per column instead of deriving them from the currently-loaded page. - equals/doesNotEqual now use text input in the advanced filter popup. - FilterPopupMenuOptions.advancedFilterType lets callers force the filter mode (text/numeric/date) per column instead of inferring it from rows. - AdvancedFilterType is exported from the public API. - Guard _debugCheckDataType so "Is Null"/"Is Not Null" conditions (null value) no longer throw FlutterError on refresh or sort.
|
Hi @ariefwijaya , Thank you for sharing the details. We have reviewed your requirement and have already logged it as a feature request on our end. At this time, we do not have immediate plans to include this functionality. However, it will be considered for a future release based on its priority and alignment with our product roadmap. We appreciate your understanding and patience in this regard. You can track the status of this feature request through the feedback portal using the link below: Feedback Link: Support for Customizing Filter Popup Values with Server‑Side Pagination in Flutter DataGrid in Flutter | Feedback Portal Any updates or progress related to this feature will be communicated through the feedback portal. Therefore, we are proceeding with closing this support ticket. Please note that while the Flutter SfDataGrid source code is publicly available on GitHub for transparency purposes, we do not accept direct contributions to the repository. This policy helps us maintain consistency, stability, and quality across all releases. Nevertheless, we truly value your feedback and encourage you to continue sharing your ideas and suggestions through our official support channels. Thank you for your understanding and continued support. Regards, |
Summary
This PR contains several related improvements so
SfDataGrid's built-in filters work correctly in server-side pagination scenarios, whereDataGridSource.rowsonly holds one page of data at a time:CheckboxFilterValueProvidermixin — ADataGridSourcecan opt into this mixin to supply a static list of values for the checkbox filter popup per column, instead of the default row-derived list.equalsanddoesNotEqualtotextFieldFilterTypesinDataGridAdvancedFilterHelper, enabling free-text input for these filter types in the advanced filter popup.advancedFilterTypeonFilterPopupMenuOptions— Exposes a newadvancedFilterTypefield so callers can override the filter mode (text,numeric,date) per column without relying on cell-value inference.AdvancedFilterTypeexported from public API — Re-exportsAdvancedFilterTypefrom the package's public barrel so consumers can reference the enum without reaching into internal paths._debugCheckDataTypeso that filter conditions with anullvalue (i.e. "Is Null" / "Is Not Null" filter types) no longer throw aFlutterErrorwhen rows are refreshed or a column is sorted.Motivation
When using server-side pagination,
DataGridSource.rowsonly contains one page of data at a time. This causes multiple problems with the built-in filter UI:Checkbox filter:
CheckboxFilterViewderives its unique values fromDataGridSource.rows, so values from other pages disappear from the filter list on navigation, making the checkbox filter unusable for server-side grids. TheCheckboxFilterValueProvidermixin lets the source provide the full value set explicitly.Advanced filter (equals/doesNotEqual):
equalsanddoesNotEqualwere only driven by a dropdown populated from the current page's rows. Values from other pages are not available, making exact-match filtering impractical. Users who know the exact value they want should be able to type it directly instead of selecting from an incomplete list.Advanced filter (column type inference):
For server-side grids, cell values may be stored as strings regardless of the logical column type (date, numeric). The automatic
AdvancedFilterTypeinference based on cell-value type then produces the wrong filter UI.FilterPopupMenuOptions.advancedFilterTypelets the caller set the correct filter mode explicitly.Null/Not Null filter crash:
Applying an "Is Null" / "Is Not Null" filter on a date or numeric column stores
nullas the condition value. On a subsequent data refresh or sort,_debugCheckDataTypecomparednull's runtime type against the column's expected type and threw aFlutterError, crashing the grid.Usage
CheckboxFilterValueProvider
advancedFilterType on FilterPopupMenuOptions
Test plan
nullfromgetCheckboxFilterValuesfalls back to default row-derived values.effectiveRowsare checked when a filter is active; all values are checked when no filter is active.equals/doesNotEqualin the advanced filter popup shows a text input instead of a dropdown, and filtering by a typed value works.advancedFilterTypeonFilterPopupMenuOptionsforces the popup to text/numeric/date mode.AdvancedFilterTypeis importable from the public package barrel.FlutterError.