Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datagrid date format in filter text box #5430

Closed
blenke opened this issue Mar 28, 2024 · 2 comments
Closed

datagrid date format in filter text box #5430

blenke opened this issue Mar 28, 2024 · 2 comments
Labels
Type: Feature ⚙ Request or idea for a new feature.

Comments

@blenke
Copy link

blenke commented Mar 28, 2024

Is your feature request related to a problem? Please describe.
I'm using a DataGridDateColumn with a display format like this:
DisplayFormat="{0:dd-MMM-yyyy}"

If I type a date in that format in the filter text box , for instance 28-Mar-2024 it won't find anything , if i use the US format 3/28/2024 it will find a date.

Describe the solution you'd like
Would it be possible to apply a specific date format in the filter or let it use the displayformat already given? I know i can create a custom filter where this could be applied. Would be nice to get this working out of the box.

@blenke blenke added the Type: Feature ⚙ Request or idea for a new feature. label Mar 28, 2024
@stsrki
Copy link
Collaborator

stsrki commented Mar 28, 2024

The DisplayFormat parameter is used for the displaying of the cell value. If you want to have a different input format than the one that is provided by the DataGrid and by the browser you can override it by using the EditTemplate, FilterTemplate on a DataGridDateColumn.

Here is an example of a regular DataGridColumn. You can adopt the same logic for DataGridDateColumn.

<DataGridColumn Field="@nameof( Employee.FirstName )" Caption="First Name" Editable>
    <FilterTemplate>
        <TextEdit Placeholder="Search name" Text="@context.SearchValue?.ToString()" TextChanged="@(v=> context.TriggerFilterChange(v))" />
    </FilterTemplate>
</DataGridColumn>

@blenke
Copy link
Author

blenke commented Mar 28, 2024

I solved it by setting the date format on the application level in program.cs. If I set the short date there to dd-MMM-yyyy it works as expected. I want the user to be able to enter mar-2024 to get all march 2024 dates. By default my server is set to US format which is then used by the blazor application and the comparison fails.

I think in the filter you are ignoring the displayformat that is set on the column. I would expect that you first format the item text and then check if it contains the search value. A custom filter will also work but just generates unnecessary code.

@stsrki stsrki closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature ⚙ Request or idea for a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants