The "DateOnly" filter for OEnumarable in RadzenGrid is not used #1490

Closed
opened 2026-01-29 17:54:22 +00:00 by claunia · 0 comments
Owner

Originally created by @simonluebker on GitHub (Nov 20, 2024).

Hey there,
in #1772 the IConvertible Exception is gone but now if the filter is set, it returns string empty. This is because in line 790
the comparison to DateOnly is missing and then in line 810, string emtpy is returned

So the Fix would be to add DateOnly type comparison :

else if (column.FilterPropertyType == typeof(DateTime) || column.FilterPropertyType == typeof(DateTime?) || column.FilterPropertyType == typeof(DateTimeOffset) || column.FilterPropertyType == typeof(DateTimeOffset?) || column.FilterPropertyType == typeof(DateOnly?))

and to use the value instead of parsing it in line 802

like return $"{property} {odataFilterOperator} {(column.FilterPropertyType == typeof(DateOnly?) ? value : DateTime.Parse(value, CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.RoundtripKind).ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture))}";

Thank you,
best regards

Originally created by @simonluebker on GitHub (Nov 20, 2024). Hey there, in #1772 the IConvertible Exception is gone but now if the filter is set, it returns string empty. This is because in line [790](https://github.com/radzenhq/radzen-blazor/blob/e707b99860b4e5a4028fddd82693579bd3b67adf/Radzen.Blazor/QueryableExtension.cs#L790) the comparison to DateOnly is missing and then in line [810](https://github.com/radzenhq/radzen-blazor/blob/e707b99860b4e5a4028fddd82693579bd3b67adf/Radzen.Blazor/QueryableExtension.cs#L810), string emtpy is returned So the Fix would be to add DateOnly type comparison : `else if (column.FilterPropertyType == typeof(DateTime) || column.FilterPropertyType == typeof(DateTime?) || column.FilterPropertyType == typeof(DateTimeOffset) || column.FilterPropertyType == typeof(DateTimeOffset?) || column.FilterPropertyType == typeof(DateOnly?))` and to use the value instead of parsing it in line [802](https://github.com/radzenhq/radzen-blazor/blob/e707b99860b4e5a4028fddd82693579bd3b67adf/Radzen.Blazor/QueryableExtension.cs#L802) like ` return $"{property} {odataFilterOperator} {(column.FilterPropertyType == typeof(DateOnly?) ? value : DateTime.Parse(value, CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.RoundtripKind).ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture))}";` Thank you, best regards
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1490