I have a grid that is displaying a date of 1/1/2013 (It was populated from a DateTime object 1/1/2013 5:00 AM in UTC time)
It displays in the grid as 1/1/2013. However when I do the following to get the underlying record for the row and log the columns value to the console it is now incorrect and displays in the console Mon Dec 31 2012 19:00:00 GMT-0500 (Eastern Standard Time)
I use the following calls to get at the record that was used to populate the grid
var grid = patientInfo.data("igGrid");
var records = grid.dataSource.dataView();
var activeRecord = records[index];
What can I do to keep the correct date/time in the grid. I have tried converting all DateTime objects ToUniversalTime and that did not help
It also does not work
It seems that the grid should do this automatically. If I put a date into the grid and then ask the grid for the record I Expect the record to be accurate
Hello Ddally,
I have heard back from the development team that Javascript Date objects are always created in the client's timezone, the Grid uses a formatter function to display them in UTC. So you can use the same function to get a string representing the Date in UTC
$.ig.formatter($("#grid").data("igGrid").dataSource.dataView()[0].PatientDateOfBirth, "date", "dateTime", true, true);
I you use MVC databinding logic the server will send offsets for each DateTime object in the data source. These are present in the metadata property of the dataSource.
$("#grid").data("igGrid").dataSource._metadata
Please let me know if you have any further questions regarding this matter.
Hello Donald,
I have investigated your issue and, I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 134733. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
I will leave this case open and update you with any new information after the review. You can also continue to send updates to this case at any time.
You can view the status of the development issue connected to this case by going to the “My IG” tab on our website, hovering to the "My Support Activity" dropdown and selecting the "Development Issues" tab.
Please let me know if you need more information.
Unfortunately your example is html, and my code uses MVC.
Here is my console output in Chrome. You will see below that the dates that were added for Fred and Jane were 1/1/2013 12:00 AM, It displays 1/1/2013 in the grid but when retrieved it is incorrect.
I have added some MVC code that demonstrates the problem
Here is the Data model I am using
using System; using System.Runtime.Serialization;
namespace DateTestMVC.Models { [DataContract] public class DataModel { [DataMember] public string PatientListMembersID { get; set; } [DataMember] public string PatientLastName { get; set; } [DataMember] public string PatientFirstName { get; set; } [DataMember] public DateTime? PatientDateOfBirth { get; set; }
public DataModel(string id, string first, string last, DateTime date) { PatientListMembersID = id; PatientFirstName = first; PatientLastName = last; PatientDateOfBirth = date; } } }
Here is my Controller and the way the data is added.
The first 2 items will display the correct date in the grid but consol.log will show the date as 12/31/2012.
public class DefaultController : Controller {
public ActionResult Index() {
var members = new List<DataModel>();
members.Add(new DataModel("1", "Fred", "Test", new DateTime(2013, 1, 1)));
members.Add(new DataModel("2", "Jane", "Test", new DateTime(2013, 1, 1).ToUniversalTime()));
members.Add(new DataModel("3", "Will", "Test", new DateTime(2013, 1, 1, 23, 0, 0)));
return View(members.AsQueryable());
}
Here is my View
@using DateTestMVC.Models
@using Infragistics.Web.Mvc
@model IEnumerable<DataModel>
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/infragistics.loader")
@(Html.Infragistics().Loader()
.ScriptPath(Url.Content("~/Scripts/Infragistics/"))
.CssPath(Url.Content("~/Content/Infragistics/"))
.Resources("igCombo,igGrid.Filtering")
.Theme("infragistics")
.Render()
)
@{ ViewBag.Title = "Index"; }
<h2>Grid</h2>
<div>
@(@Html.Infragistics().Grid<DataModel>()
.ID("grid").PrimaryKey("PatientListMembersID")
.LoadOnDemand(false).AutoGenerateColumns(false).AutoGenerateLayouts(false).EnableUTCDates(true)
.EnableHoverStyles(true).RenderCheckboxes(true).LocalSchemaTransform(true).AutoCommit(true)
.Columns(columns => {
columns.For(x => x.PatientListMembersID).Hidden(true);
columns.For(x => x.PatientLastName).Width("100").HeaderText("Last Name");
columns.For(x => x.PatientFirstName).Width("100").HeaderText("First Name");
columns.For(x => x.PatientDateOfBirth).DataType("date").Format("date").Width("100").HeaderText("DOB");
})
.Features(feature => {
feature.Sorting().Mode(SortingMode.Single);
feature.Selection().Mode(SelectionMode.Row).MultipleSelection(true);
feature.RowSelectors().EnableCheckBoxes(true).EnableRowNumbering(false);
feature.Resizing().AllowDoubleClickToResize(true);
.DataSource(Model)
.DataBind()
.Width("400")
.Height("500")
.Render())
</div>
<script type="text/javascript" language="javascript">
$.ig.loader(function () {
var grid = $('#grid');
if (grid) {
var igGrid = grid.data("igGrid");
var records = igGrid.dataSource.dataView();
var recordCount = records.length;
for (var idx = 0; idx < recordCount; idx++) {
var record = records[idx];
console.log(record.PatientFirstName, record.PatientDateOfBirth);
});
</script>