Hello,
We are attempting up update from version 16.2 to 17.1. We are using a row edit dialog to edit existing DateTime data and the date is changing on submit.
The date we are sending on the server is 04/01/2013 at midnight. At first, we tried updating the row without changing any data. It appeared the date was changing, but we found that EnableUTCDates was set to TRUE for the DateTimeEditor, but was not set for the Grid. So we set this option to TRUE for both the grid and editor. This fixed the initial issue. Or second test involved updating the date itself. We changed the date from 4/1/2013 to 4/2/2013 and then back to 4/1/2013 using the datepicker. When we do this, the date is changing when it gets to the server.
In 16.2, the data looked like this when it got to the server:
{{"Id": 59,"StartDate": "2013-04-01T00:00:00Z"}}
In 17.1, we are seeing the following date:
{{"Id": 59,"StartDate": "2013-04-01T16:00:00Z"}}
What are the recommended settings for preventing a date from changing on submit to the server? We would expect this to work exactly the same as it did in 16.2 as we didn't have any problems with the dates in that version.
Thanks,
Paul
Hello Paul,
You are welcome!
This probably goes back to how DateTimeKind.Unspecified is not consistent when deserialized between different browsers. Generally speaking such DateTime-s are not really points in time and should be given context on an application level to mean anything. Regardless, I'll speak with my colleagues that develop igDatePicker and see if their opinion is that we can improve this scenario. As you have found (and I verified) that specifying DateTimeKind for this option's value is a clean solution I will not log any work items internally for this at the moment. I'll let you know should this change.
Thank you for using Ignite UI!
Best regards,
Stamen Stoychev
Thanks for the update, this appears to be working in our main solution when using the infragistics.ui.editors.js from the GitHub. We'll use that code for now and we don't need a private build.
One other thing I just wanted to mention is that we found a situation where the time was still changing when we set the MinValue of the DateEditorOptions. This would only happen in cases where the date was actually typed in (and the datepicker was not used), even if the validation wasn't triggered. We originally had this set to updatingSetting2.DateEditorOptions.MinValue = new DateTime(1900, 01, 01);
After changing this to updatingSetting2.DateEditorOptions.MinValue = new DateTime(1900, 01, 01, 0, 0, 0, DateTimeKind.Utc); , this worked as expected as well.
Thanks for your help with this.
I am sorry for the delayed response and thank you for the sample that you provided!
I believe what might have been happening was that you experienced a bug in igDatePicker that has been recently resolved. This is the GitHub issue for your reference: https://github.com/IgniteUI/ignite-ui/issues/1109 . I am attaching back the same sample but using separate references to the required components so that I could mix in CDN links pointing to the latest 17.1 branch on GitHub. The roundtrip now looks correct to me. The only additional thing I did was to set enableUTCDates back to true for the grid so it can send UTC to the server. The roundtrip wasn't incorrect previously but you would see the date in your local timezone otherwise so it could feel wrong (even though it would be the exact same point in time).
The fix will be released as a whole-package build with the next SR. In the meantime you could either stick to referencing the editors from GitHub or request a private build to be composed for you so that you have everything in one place locally.
Please, let me know if you have further questions or comments!
Hi Stamen,
I've attached an example of what I am seeing. The first two rows have a Start Date column set. Can you please let me know what settings I should be using so that the date doesn't change? To duplicate this, edit the first row in the grid. Change the date from 4/2/2013 and then back to 4/1/2013. Then debug the server code. In HomeController.SaveChanges_Generic, there is a line: 'Console.WriteLine(column.Value);'. Just put a break-point on that line. You'll notice that the time changes when you submit. Can you provide the settings needed to get this example to work without the time changing?
You're right, and it is being loaded as DateTimeKind.Unspecified. We are not currently using GridDataSourceAction though (I can't remember why, but I'm pretty sure this has to do with the fact that our Url to get the data requires some extra parameters in addition to path and layout. So GridDataSourceAction doesn't work for our situation). We are currently using GridModel.GetData(path, layout) to get the data. Is there a way to force this method to interpret the DateTimes as UTC?
We did as you suggested and hard-coded this to be specified as UTC. This does make sense on the "view" side; however, I think there is still something that is off when the value changes in a RowEditDialog. When changing the value using the datepicker, the date that is submitted to the server is still '4/1/2013 8:00:00 PM' when EnableUTCDates is true or false.
An isolated sample would be helpful. If you are unable to duplicate this, then please send me basic sample using an MVC grid with a RowEditDialog and I think I should be able to duplicate it as long as I have an initial sample.