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://www.infragistics.com/community/forums/t/80982.aspx
I have enabled UtcDates, I am still facing the issue. What am I doing wrong?
Thanks.
Hi zep lin,
Thank you for posting in our forums!
I will need a little more time to investigate why the dates continue to be offset while EnableUTCDates is true. First, please answer the following questions for me so I may better assist you with this:
1.) Which version and build of IgniteUI you are using. e.g. 14.1.20141.2249
2.) How is the Date being passed into the grid? Are you sending it directly as JSON from the server?
Looking forward to hearing from you.
Thanks Michael for the response.
1) I am using 2013.2 version of infragistics. Version 4.13.2.2157
2) This method converts my collection to json and then passes it on to the grid:
public ActionResult ConvertToJson<T>(ResponseWrapper<T> result) { ResponsePacket<T> dataViewModel = new ResponsePacket<T>(); JsonResult jsonResult = new JsonResult(); var pageSize = HttpUtility.ParseQueryString(Request.Url.Query).Get("pageSize"); var pageIndex = HttpUtility.ParseQueryString(Request.Url.Query).Get("page"); if (pageSize == null || pageIndex == null) { dataViewModel.Records = result.Content; dataViewModel.RecordCountKey = result.recordCountKey; jsonResult.Data = dataViewModel.Records; jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; } else { dataViewModel.Records = result.Content.AsQueryable(); dataViewModel.RecordCountKey = result.recordCountKey; jsonResult.Data = dataViewModel; jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet; } return jsonResult; }
The grid model is set up on my controller & the gridModel is generic in a way that it is for all the entities & the columns are set up dynamically like this :
gridModel.Columns.Add(new GridColumn() {
//record is my result set which contains the MetaData of the database table HeaderText = record.DisplayName, Key = record.ColumnName, DataType = record.DataType });
Hello Zep,
Thank you for your patience!
I have reviewed the provided information so far and I have tried to reproduce the issue by the given code, but I didn't had any access.
Could you please provide an isolated working code sample so I can test it and investigate the source of the issue?
Thank you in advance!
Hello Denis,
I think it has something to do with the timezone but I am not sure how to set the correct time zone.
This stackoverflow post is exactly what I am experiencing & the answers there suggest of using the correct time zone. This is the link , please have a look here. How can I set the correct time zone. My local time zone is Gmt +5.
http://stackoverflow.com/questions/7556591/javascript-date-object-always-one-day-off
The first answer on StackOverflow is this :
Notice that Eastern Daylight Time is -4 hours and that the hours on the date you're getting back are 20.
-4 hours
20
20h + 4h = 24h
which is midnight of 2011-09-24.
You're getting the right date, you just never specified the correct time zone.
If you need to access the date values, you can use getUTCDate() or any of the other getUTC*() functions:
getUTCDate()
getUTC*()
var d, days; d = new Date('2011-09-24'); days = ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat']; console.log(days[d.getUTCDay()]);Do I have to pass all of my dates through this routine & add +4 hours to them or is there another way. Thanks.
var d, days; d = new Date('2011-09-24'); days = ['Sun', 'Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat']; console.log(days[d.getUTCDay()]);
You can use a formatter function to workaround this.
Please review the attached sample.
Thanks I will implement it in 3-4 days and let you know how it goes. Thanks for the help.
I will be awaiting your feedback.
Hello,
I'm just following up to see if you need any further assistance with this issue. If so please let me know.