MudDataGrid: FilterTemplate for DataGridFilterMode.Simple#12802
MudDataGrid: FilterTemplate for DataGridFilterMode.Simple#12802danielchalmers merged 16 commits intoMudBlazor:devfrom
Conversation
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridSimpleFilterTemplateTest.razor
Outdated
Show resolved
Hide resolved
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridSimpleFilterTemplateTest.razor
Outdated
Show resolved
Hide resolved
|
I've done some cursory looking and have two questions for when I get home tonight.
|
Hard to tell. It works fine in docs solution.
Currently is not possible to have dropdown filter especially not with multiselect values. What this enables: |
Well thank you very much for the work on it I will take a look when I get back home I appreciate it |
Are we talking about example from #12130? I’m not sure why it would be hard to tell, there are specific errors listed. |
|
First, I need you to fix the try mud example so I can use it as a reference example. Edit the linked issue and make one that works with try mud, compiles, and allows me visibility. Second, I’m not objecting to adding API surface if it is truly necessary, but I want the necessity explained clearly. We already have FilterTemplate. What concrete capability does SimpleFilterTemplate add that could not be provided by rendering FilterTemplate in DataGridFilterMode.Simple with the existing FilterContext? Right now the PR proves that simple mode does not render FilterTemplate, but that only shows a gap in the current implementation. It does not yet show that a new public property is required. If the real requirement is multi-value filtering, then the important question is whether that needs a new template API, or whether simple mode should reuse FilterTemplate and expose the same filter context/actions there as well. |
I dropped everything and implemented with FilterTemplate. |
|
Just note it was a question not a change request direction. It may really need to be done separately. You aren't sure why? I'm looking through all the code now fyi. |
versile2
left a comment
There was a problem hiding this comment.
I like the move to reuse FilterTemplate in simple mode instead of adding SimpleFilterTemplate. That feels like the right direction.
My remaining concern is the implementation. The built-in simple rows support multiple filters on the same column independently, but the custom FilterTemplate path looks like it reuses the shared column FilterContext and swaps the FilterDefinition while rendering. I think this needs a per-filter FilterContext in simple mode so custom filters behave the same as the built-in ones.
I’d also want one regression test for that case, and the docs example should be clearer about when it is using custom filter logic versus standard behavior.
Lastly doing it this way gives access to the Apply and Clear actions of FilterTemplate context (HeaderCell) and they should work if you wanted to update the example to use that context action.
...Blazor.Docs/Pages/Components/DataGrid/Examples/DataGridFilterTemplateSimpleModeExample.razor
Show resolved
Hide resolved
|
Please take a look at the latest changes. |
|
Thank you! |
Description
This PR extends
Column.FilterTemplatesupport toDataGridFilterMode.Simpleand aligns custom filter actions with the UI surface that owns the filter experience. Additionally includes a Docs rewrite so everything makes sense.Before this change:
Column.FilterTemplateworked inColumnFilterMenuandColumnFilterRowSimplemode always used the built-in editor for each filter rowFilterFunctionpredicates could remain attached when a Simple filter row was switched to another columnWith this change:
Column.FilterTemplatecan now customize individual filter rows inDataGridFilterMode.SimpleFilterContext.Actionsare bound by the active filter UI owner:MudDataGridinSimpleHeaderCellinColumnFilterMenuFixes
Changes
Core Implementation
MudDataGrid.razorColumn.FilterTemplateinside built-in Simple filter rowsMudDataGrid.razor.csFilterContextinstances with grid-owned actionsCloseFilterUIAsync()for the Simple filter panelFilterContext.csFilterContext<T>typeFilterActions.CloseFilterUIAsyncHeaderCell.razor.csColumnFilterMenuFilter.csFilterDefinition.FilterFunctionwhen a filter row changes columnsDocumentation
DataGridPage.razorFilterContext<T>andActionsguidance where filter templates are introducedFilterCaseSensitivityexplanationDataGridFilteringExample.razorDataGridFilterTemplateSimpleModeExample.razorFilterTemplateMudDataGrid.FilterTemplateDataGridAdvancedFilteringExample.razorColumn.FilterTemplateinColumnFilterRowandColumnFilterMenuUsage
Column template in
SimplemodeTests
Column.FilterTemplaterendering and filtering inSimpleFilterFunctionbeing cleared when a filter row changes columnsFilterContext.Actionsapply/clear behavior inSimpleFilterContext.Actions.CloseFilterUIAsync()in bothSimpleandColumnFilterMenuNotes
FilterContext.Actionsnow follow the visible filter UI owner instead of always routing throughHeaderCellMudDataGrid.CloseFilterUIAsync()closes the Simple filter panel and removes incomplete value-required filtersScreenshots
The SimpleFilterTemplate allows replacing the default text input with custom controls like dropdowns in Simple filter mode, providing a better user experience for fields with predefined values.
Before

After
Checklist: