Hi,
My dates in the grid are being displayed one day behind even though I have set the EnableUtcDates(true).
I have enabled UTCDates in my grid model through the MVC GridModel() method like this :
GridModel GetGridModel(selectedRow) {
GridModel gridModel = new GridModel(); gridModel.ID = "MyGrid"; gridModel.AutoGenerateColumns = false; gridModel.PrimaryKey = selectedRow.PrimaryKey; gridModel.Width = "100%"; gridModel.Height = "400px"; gridModel.EnableUTCDates = true;
.... ....// other settings
..... ......
return gridModel;
}
1) The date I get from server is 7/1/2012 00:00:00.000 & the grid displays 6/30/2012 (Here the month & day both are decremented because of 1st date)
2) The date I get from server is 11/11/2014 00:00:00.000 & the grid displays 11/10/2014 (Here only the day is decremented)
---------------
This issue is also discussed here but the answer suggests to enable UTCDates feature of the grid.
http://es.infragistics.com/community/forums/t/80982.aspx
I have enabled UtcDates, I am still facing the issue. What am I doing wrong?
Thanks.
If you’re using also any of the editor controls (igDatePicker and igDateEditor) you should also set EnableUTCDates to true for them as well in order to have consistent dates from the same time zone.
I was facing the same problem. The issue was this: I had enabled UTCDates in the grid but I hadnt set UTCDates in my igEditor therfore the value I set from igEditor was being set as one day behind in the igGrid. Thanks for the question & your help. Appreciate it.
Hello Zep,
Have you been able to resolve the issue? If not so I am still awaiting your sample project.
Hello zep lin,
The EnableUTCDates option only formats the date it received from the server to UTC.
Basically the date values go through a formatter method that depending on the EnableUTCDates option either builds the value with the standard date object methods in local time (getFullYear(), getMonth(), getDate(),getHours() etc.) or via the methods UTC equivalents in UTC time ( getUTCFullYear(), getUTCMonth(), getUTCDate(), getUTCHours() etc.). The formatted value is what you’ll see in the cells of the grid once it's rendered.
This is also true for the igDatePicker and igDateEditor.
In your case most probably the dates you send from the backend are not in UTC (DateTime.Kind is not UTC but Local) which means that they have their own offset from UTC which will not be taken into consideration in cases where the Json data is manually retuned from an action result.
Best Regards,
Maya Kirova
Product Developer
Infragistics, Inc.
http://es.infragistics.com/support
Provide isolated sample project replicating your issue so I can be able to investigate this behavior.
Hello Denis,
I implemented your solution, Its not working for me. The following was the result I was getting BEFORE implementing your soultion:
The date on the server is : 2014-11-12 00:00:00.000
The date in the grid is : 11/11/2014 _7:00 PM
(12th date becomes 11th)
After I implemented your sample project I get a completely wrong date, I cant figure out the implementation details of your formatToServerTimeZone(date) function, is it specific to Pennsylvania? Are Daylight Savings setting different for every region ? Then this would be a problem. I dont want to hardcode the daylight saving settings. The following line does not make sense to me and if I have to modify it according to my region then this would become region specific, I dont think there is Daylight Saving in my country right now so what should be the setting?
Also one more thing.
I have a form (Master) also above the grid (Detail) . The same date 2014-11-12 00:00:00.000 from server is loaded in the form's datePicker and the date is displayed correctly like this : 11/12/2014
There is an event bound to this datePicker, on its selection changed event, the date of this (master's) datePicker is used to set the date in my Grid (detail). And the date 11/12/2014 becomes 11/11/2014 _7:00 PM . And if I commit the data the server's date also becomes 11/11/2014 00:00:00.000 BUT if I use the datePicker inside the grid (detail) and select 11/12/2014 then the correct date is displayed in the grid as well as on committing the row the server's date becomes 2014-11-12 14:00:00.000 and is displayed correctly next time in the grid.
From what I understand is that if I change the grid's date column through my master's datePicker, the date becomes one day behind, If I set the date through the grid's columns datePicker the date displays alright and the server also stores it correctly.
var date = $("#voucherPartyRefDate").igEditor("value"); // get date from master's datePicker
$("#voucherDetailGrid").igGridUpdating("updateRow", detailHeaderPk, { //set date of detail(grid's) datePicker
vchr_dtl_ref_dt: date
-----------------------------------
If this is messing up the date than what should be done ? Is there another way to set the date of grid date column based on the date selected from master's igDatePicker?