Skip to content

Replies

0
zep lin
zep lin answered on Nov 10, 2014 6:50 AM

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?

Thanks.
            

0
zep lin
zep lin answered on Oct 31, 2014 11:42 AM

Thanks I will implement it  in 3-4 days and let you know how it goes. Thanks for the help.

0
zep lin
zep lin answered on Oct 31, 2014 10:03 AM

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.

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:

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.

0
zep lin
zep lin answered on Oct 28, 2014 6:25 AM

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
                    });

0
zep lin
zep lin answered on Oct 23, 2014 10:17 AM

I am also having the same issue,  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 & the grid displays 6/30/2012  (Here the month & day both are decremented)

2) The date I get from server is 11/11/2014 & the grid displays 11/10/2014 (Here only the day is decremented)

0
zep lin
zep lin answered on Oct 10, 2014 6:58 AM

Just implemented it. Working perfectly. Thanks again.

0
zep lin
zep lin answered on Oct 9, 2014 4:50 PM

Thanks alot Denis, I have not yet ran the sample but I think this will solve it. I will get back to you after implementing it tomorrow morning. Thanks for your help. Really appreciate it.