Hello,
We are currently facing an issue when updating a row that contains a date column, the value is not serialized with the right regional format :
In the datasource, we have the value like this (which match our value in database) :
DATE : Thu Jan 26 2023 11:58:08 GMT+0100 (heure normale d’Europe centrale)
It also displays well on the grid with the right regional format, but when we update a cell (not the date column) on this row and using the saveChanges updating grid method, the serialize date looks like this :
DATE : "2023-01-26T10:58:08.000Z"
It doesn't match our database value anymore, it has 1 hour less.
We tried to set enableUTCDates: false, because as it is indicated in the documentation : "It serves the purpose to specify dates serialization." but it doesn't solve the problem, so maybe it doesn't affect the serialized values for updating.
Is there another option to keep the right regional format when serializing updating row values ?
Thank you for the answer.
Hello Vincent,
Thank you for posting into our community!
I have been looking into your question and I have prepared a small sample trying to reproduce the described behavior, however, on my side I was not able to reproduce it and the dates are displayed in the proper format.
Additionally, as I am not sure how the updating is performed on your side and the overall configuration of the igGrid control, in the attached sample I am using batch updating and setting the editMode to row as well as providing a format for the date column. On my side, everything works as expected and the date values are displayed properly.
Here could be found my sample for your reference.
Having this in mind, in order to assist you further, it would be highly appreciated if you could provide me with a sample that demonstrates the behavior on your side.
Having a sample that I can debug on my side will be extremely helpful in finding the root cause of this behavior and providing you with a solution as soon as possible.
Thank you for your cooperation. Looking forward to your reply.
Sincerely,Riva IvanovaAssociate Software Developer
Sorry maybe I haven't been clear enough to explain my issue : it is not a problem of displaying, the dates are correctly displayed with the right format in our grid. The issue happens only during updating, i will add more informations :
First, we are using editMode as cell (I don't think it has an impact on the problem but you can maybe reproduce it better)
If i adapt your sample with my datasource, it could look like that :
var data = [{ ProductID: 1, ProductName: "ASP.NET Controls", DevelopmentTeam: "Team A", ReleaseDate: new Date("2023-01-26 11:58:08.000"), }];
When i update a cell, then call saveChanges(), i can see that the row datas are sent like this to the web service :
{ProductID: 1,ProductName: "ASP.NET Controls",DevelopmentTeam: "Team A",
ReleaseDate: "2023-01-26T10:58:08.000Z"}
When the row datas are serialized to be send to the web service, the date format is not the same.
I hope it will help you to understand better our problem and maybe have an idea of what can causes this.
Thanks
Thank you for following up!
After further investigating this matter, I need to ask for some additional information.
You have mentioned that the row data is sent in the following format:
{ProductID: 1,ProductName: "ASP.NET Controls",DevelopmentTeam: "Team A", ReleaseDate: "2023-01-26T10:58:08.000Z"}
By “row data is sent” do you refer to the serialized transaction log which is passed as a JSON string and is available in the form field ig_transactions?
Furthermore, are there any additional configurations upon cell editing? I am asking this question, because you have mentioned that the editMode is set to cell, however, the generated transaction corresponds to the row editMode.
Additionally, you have mentioned that when editing any cell, the date value is sent incorrectly, however, when using editMode cell, the generated transaction contains information only for the updated cell and not the other ones in the record.
Nevertheless, I have tried reproducing the described behavior when the editMode is set to row with date values similar to the provided one, however, on my side I am still not able to reproduce it and the row data generated in the ig_transactions seems correct. Additionally, when testing with editMode set to cell and editing any other cell different from the date cell, the values only for the edited cells are generated in the ig_transactions.
Having this in mind, could you please clarify what kind of additional configurations are applied, e.g., columnSettings for the igGridUpdating feature, editor types, editor providers, etc.
Additionally, if possible, it would be extremely helpful if you could try and implement any important aspect of the igGrid control in a small sample and attach it to this forum thread.
Sincerely, Riva Ivanova Associate Software Developer
Hello !
I should have add more information, I'm not talking about ig_transactions, it works just like you said no problem about that.
We are using Rest editing, our dataSource is builded with : jQuery.ig.RESTDataSource.
I found this example on the documentation about it that can help me to explain our problem :
When i said row datas, i meant the datas that are sent in the request payload, the updated entities, where every columns datas of the row are visible, even in editMode cell.
By the way on the screen, I can see that the dates seems well formated compared to us, here are the datas in the request payload, and on the right the dates we have in database :
It might be difficult to give you a sample because of the complexity of our application, but maybe I can found an editable sample working with dates on the documentation or if you have one to send me, then compare it to what we have on our side to check if some options we have could have an impact on the dates serialization.
Thank you for your follow-up message!
I have modified the previously attached sample using REST editing and I was able to reproduce the described behavior and what I could say is that the dates by default are sent in UTC, hence the date values being one hour less in this specific case.
Having this in mind, since I am not sure how the updating functionality is implemented on your side, what I could suggest is sending an additional value that states the time offset of the date value. Then, this offset, which is presented in minutes, could be used to compare the date sent in the request playload to the one in the database.
Sending an additional value when the editMode is set to cell could be achieved similar to the following:
features: [ { name: "Updating", editMode: "cell", editCellEnding: function (evt, ui) { if (ui.oldValue === ui.value || ui.value instanceof Date && ui.oldValue.getTime() === ui.value.getTime()) { return; } var record = $("#grid").igGrid("findRecordByKey", ui.rowID); record.offset = new Date().getTimezoneOffset(); $("#grid").igGridUpdating("updateRow", ui.rowID, record); }, }, ],
The result from the above configurations could be observed in the attachments below. On my side, which is +02:00, the time part of “Release Date” shows 11:58AM and the value sent in the request playload is 2023-01-26T09:58:08.000Z, i.e., 2 hours less which corresponds to the value of the additional offset property -120 minutes.
Here could be found the modified sample demonstrating this approach.
Please test it on your side and let me know if you need any further assistance regarding this matter.
Looking forward to your reply.
I tried your solution and it worked well, however we decided to manage the date format on server side.
The question was more to know if it was normal, a bug, or if an option existed to send dates in other format than UTC. So it is not the case but that's alright we found a solution to this issue.
Thank you for your explainations.
I am glad that you found a solution and managed to achieve your requirement.
Thank you for using Infragistics components.
Regards,Riva IvanovaAssociate Software Developer