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

Date and Datetime fields when editing #997

Open
unle70 opened this issue Jun 14, 2021 · 5 comments
Open

Date and Datetime fields when editing #997

unle70 opened this issue Jun 14, 2021 · 5 comments

Comments

@unle70
Copy link

unle70 commented Jun 14, 2021

Hello,

I'm working with revision 5.5.5 of jqGrid.
Currently the documents do not mention support for column types "date" and "datetime-local" when editing. I have found by experience that actually those types CAN be used and can (almost) work well.

The only issue now is that the validator is rejecting the values. Looks like the validator is trying to use the "formatoptions.newformat" for validating. I believe this is not optimal. The format created by the browser is something like: "yyyy-mm-ddTHH-MM-SS" (note the "T" in the middle). The validator is always failing due to this. Probably there should be a separate parameter for input validation template.

I have been able to overcome this issue by using the custom validator.
If and when possible, I would recommend adding proper support for these field types as I'm sure many users would love to use them.

@tonytomov
Copy link
Owner

Hello,

Thank you.

The validator works only with type of data and type time and not datetime.

I have added support in parseDate function to check date-time field, but it is not very well tested.
This is something that really should be improved and I will make this possible this and next week.

Kind Regards

@unle70
Copy link
Author

unle70 commented Jun 15, 2021

Hi Tony,

That sounds just great.
I have noticed another issue with this type of fields (datetime-local). When doing Form-Edit or Inline-Edit, the original column value is not properly copied to the edit field in the edit form. Fields of other types are set correctly, just this one is left blank.

Thanks.

@tonytomov
Copy link
Owner

Hello,

Can you please provide a example of that?

Thanks

@unle70
Copy link
Author

unle70 commented Jun 15, 2021

Hi Tony,

Providing an example is always a challenge for me. In my environment I have created a kind of "generator" on the server which automatically produces the client-side configuration. It produces a HUGE and very complicated code as it supports almost all the features that jqGrid has to offer (just for future flexibility). If I need to produce a demo code I cannot use this generator environment and have to start from zero and make it.
I will try, but it might take some time.

Thanks,
Udi

@unle70
Copy link
Author

unle70 commented Jun 20, 2021

Hi Tony,

Sorry again that I did not help with preparing the example for you debug this issue properly.
In the meantime I think I can already understand why this is happening so if one day you get around to this, here is the issue:

It's exactly the same as the original problem I told you about (above). The datetime input expects this "T" as a separator between the date and time. In the main grid I'm using formatoptions/newformat: 'Y-m-d H:i'. This means the grid text has this "space" instead of a "T" (for readability). When you open the edit-form and copy the value to the INPUT fields, the default un-format does not replace this space back into "T". Then the $('input').val(grid-value) statement cannot process correctly.
Now I have added my own custom un-format which simply replaces the space with a "T". Everything works fine after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants