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
Hello Donald,
Please let me know if you need any further assistance regarding this matter.
Unfortunately that did not solve my problem..
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I was able to log the date in the Firefox console correctly.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if I can provide any further assistance.
Sincerely,
Prabha
Thanks for the sample you are using, updating now to simulate what I am doing and hopefully the problem will be determined one way or the other
Hello Ddally,
Please let me know if I can provide any further assistance regarding this matter.
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>
I have opened a support request(CAS-110970-B0L6H5) for this forum post so we may research this behavior further. Please use the following link to log onto your account at Infragistics.Com:
https://ko.infragistics.com/my-account/support-activity
Once you are logged onto your account, go to My Support Activity to view the progress of this support request. An update will be sent to you in the support request with any new information we find.
Please let me know if you have any questions.
Looks like for null dates it is adding  
It does spit out a date, it just spits out an invalid formatted date according the the javascript deserializer
Nevermind, it looks like the formatter will spit out a valid date
It also does not work