DateTime and DateTimeOffset Filter Value Formatting

Currently the filter value for a DateTime or DateTimeOffset is shown as "yyyy-MM-dd HH" in a Data Grid column filter (advanced mode), hiding the minutes and seconds. This is shown as "yyyy-MM-dd HH:mm:ss" in a RadzenDataFilter. Is this intentional, or is it possible to specify the filter format

I'm not sure if the Filter format is tied to the column formatting, but just in case it is, I am using the following for this column : FormatString="{0:yyyy-MM-dd HH:mm:ss.fff}"

Data Grid column filter
image

Data Filter
image

At the moment it’s not possible to set format for the DatePicker in the DataFilter component. You can specify custom FilerTemplate and set desired properties.

Ok, thanks for confirming. Is this something that you may look into adding into your roadmap?

We don’t have it in our roadmap however we always accept pull requests!

Ok, thanks. I have found the issue.

FormatString in RadzenDataGridColumn requires the format to be specified including the zero Index i.e {0:xxx} whereas the RadzenDatePicker DateFormat parameter just takes the format specifier.

FormatString parameter is used directly as below:

string.Format(Grid?.Culture ?? CultureInfo.CurrentCulture, FormatString, value)

So to work with this, you have a method (replicated 3 times) getFilterDateFormat which attempts to pull the format part out of RadzenDataGridColumn.FormatString which does a split on ':' and only takes the part at index one in the resulting list meaning that if you include any additional colon chars, anything else will be ignored.

I think the correct fix would be to remove the requirement to include {0: and } in the FormatString parameter and add this into calls of string.Format then update getFilterDateFormat to remove any processing.

I'm happy to work on this, if you agree with my suggestion?

Not sure how this is related DateFilter component.

RadzenDataGridColumn has a parameter FormatString which has to have the string.Format index included. In my case I've set to "{0:yyyy-MM-dd HH:mm:ss.fff}"

For Advanced filter mode, RadzenDataGridHeaderCell calls getFilterDateFormat which pulls the FormatString from the associated column, splits on colons and returns the second part which in my instance returns "yyyy-MM-dd HH"

A RadzenDataFilterItem has the same getFilterDateFormat method, but works off it's own FormatString property, however does have the same issue.

To replicate this in your demos:

DataGridAdvancedFilterPage
Replace

<RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:d}" />

with

<RadzenDataGridColumn TItem="Employee" Property="BirthDate" Title="Birth Date" FormatString="{0:yyyy/MM/dd HH:mm:ss}" />

image

DataFilterPage
Replace

<MyCustomDataFilterProperty TItem="Order" Property="OrderDate" Title="Order Date" />

with

<MyCustomDataFilterProperty TItem="Order" Property="OrderDate" Title="Order Date" FormatString="{0:yyyy-MM-dd HH:mm:ss}"/>

image

Fix will be included in our next update early next week.