Sync date filter UI with criteria; restore dropdown footer

Add _filterContexts to track filter menu contexts per field and update their FilterCriteria when criteria change, ensuring the date filter UI stays in sync. Remove CSS that hid the native Apply/Clear footer in the date filter dropdown.
This commit is contained in:
OlgunR
2026-05-11 10:00:02 +02:00
parent d9785baf5b
commit f0259e3f78
2 changed files with 5 additions and 7 deletions

View File

@@ -33,6 +33,7 @@ public abstract class BandGridBase<TItem> : ComponentBase
private readonly Dictionary<string, EventCallback<DateTime?>> _fromCallbacks = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, EventCallback<DateTime?>> _toCallbacks = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, RenderFragment<GridDataColumnFilterMenuTemplateContext>> _dateFilterTemplates = new(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, GridDataColumnFilterMenuTemplateContext> _filterContexts = new(StringComparer.OrdinalIgnoreCase);
// --- SizeMode ---
protected SizeMode _sizeMode = SizeMode.Medium;
@@ -253,8 +254,9 @@ public abstract class BandGridBase<TItem> : ComponentBase
}
private RenderFragment<GridDataColumnFilterMenuTemplateContext> BuildDateFilterTemplate(string fieldName) =>
_ => b =>
ctx => b =>
{
_filterContexts[fieldName] = ctx;
int s = 0;
b.OpenElement(s++, "div");
b.AddAttribute(s++, "class", "date-filter-menu p-2");
@@ -322,6 +324,8 @@ public abstract class BandGridBase<TItem> : ComponentBase
};
gridRef?.SetFieldFilterCriteria(fieldName, criteria);
if (_filterContexts.TryGetValue(fieldName, out var ctx))
ctx.FilterCriteria = criteria;
_ = InvokeAsync(StateHasChanged);
}