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

[Bug]: DataGrid : DatePicker Column isn't compatible with DisplayFormat #5837

Closed
David-Moreira opened this issue Nov 11, 2024 · 9 comments · Fixed by #5841
Closed

[Bug]: DataGrid : DatePicker Column isn't compatible with DisplayFormat #5837

David-Moreira opened this issue Nov 11, 2024 · 9 comments · Fixed by #5841
Assignees
Labels
Type: Bug 🐞 Something isn't working

Comments

@David-Moreira
Copy link
Contributor

@stsrki

I Remember now why we had a separate DateDisplayFormat.
The DisplayFormat isn't really compatible with the DatePicker format style. It seems to use a string.format

DisplayFormat="{0:dd.MM.yyyy}"
UI
Image
DatePicker
Image

DisplayFormat="dd.MM.yyyy"

UI
Image

DatePicker
Image

What do you think, should we revert back?

@David-Moreira David-Moreira added the Type: Bug 🐞 Something isn't working label Nov 11, 2024
@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

Not sure. DisplayFormat is used for display in a non-edit mode. Only when the row is edited that the DatePicker is shown. Right? So then it shouldn't affect it?

@David-Moreira
Copy link
Contributor Author

David-Moreira commented Nov 12, 2024

I don-t understand your question. I just showed you the differences with the screenshots. Cell Display vs DatePicker input.

@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

I don-t understand your question. I just showed you the differences with the screenshots. Cell Display vs DatePicker input.

Sorry, I was looking at the wrong date input in the image. Yeah, I see the problem now.

Whichever path we take will be a breaking change/behavior for our users. If we tell them to now write "dd.MM.yyyy" instead of "{0:dd.MM.yyyy}" as previously, or if they replace DisplayFormat with DateDisplayFormat it is essentially the same. They need to change their code.

I'm more open to telling them to do "dd.MM.yyyy" instead of "{0:dd.MM.yyyy}" as that will not introduce any new API.

@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

Dumb idea.. What if we parse and convert "{0:dd.MM.yyyy}" to "dd.MM.yyyy"?

@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

ChatGPT 😅

public static string ConvertToSimpleDateFormat(string inputFormat)
{
     var match = Regex.Match(inputFormat, @"\{0:(.+?)\}");
    if (match.Success)
    {
         return match.Groups[1].Value;
    }  
 
    return inputFormat;
}

@David-Moreira
Copy link
Contributor Author

Well first of all why are we even using this type of format "{0:}" ? Was there a special reason for it? Seems weird to define it like this honestly. I'd expect it to work just like : "dd.MM.yyyy".
So if there's no special reason, we could consider the change in order to make it more clear. As a user I would expect "dd.MM.yyyy" instead of "{0:dd.MM.yyyy}".

Now, we could wait for 2.0 to make that breaking change, and just try to infer the proper format for DatePicker as you mention.

@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

Well first of all why are we even using this type of format "{0:}" ? Was there a special reason for it? Seems weird to define it like this honestly. I'd expect it to work just like : "dd.MM.yyyy".

I have no idea TBH. It was so long ago that I really don't know the reason by now.

@David-Moreira
Copy link
Contributor Author

David-Moreira commented Nov 12, 2024

ChatGPT 😅

public static string ConvertToSimpleDateFormat(string inputFormat)
{
var match = Regex.Match(inputFormat, @"{0:(.+?)}");
if (match.Success)
{
return match.Groups[1].Value;
}

return inputFormat;

}

Lol, don't let your "brain rot" by depending on it too much. StartsWith and EndsWith works equally well in this case. Probably more readable even.
But yea for some stuff it's easy to just not waste time thinking and jump in chatgpt.

@stsrki
Copy link
Collaborator

stsrki commented Nov 12, 2024

My brain is already rot from a lack of sleep from looking at my 1 year old 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants