Pending Review
Last Updated: 26 Sep 2019 15:06 by ADMIN
Created on: 19 Sep 2019 19:36
Category: Grid
Type: Feature Request
Support binding of grid columns to DateTimeOffset fields



I think there is a bug with the DataTimeOffset field when used in a Grid. It cannot display correctly and is showing something like /Date(1364927400000)/. I have to retrieve my data from database as DateTimeOffset format and then use a new ViewModel to convert the DateTimeOffset values to DateTime values. This is really annoying.


Could you let me know if there is a way a DateTimeOffset field can be supported in the grid? Sometimes you do have to display the time zone info.


I hope this can be fixed in a future release.




1 comment
Alex Hajigeorgieva
Posted on: 26 Sep 2019 15:06

Hi, Dave,

The Kendo UI Grid for ASP.NET MVC works with DateTime out of the box, it does not work with DateTimeOffset. Therefore I have changed this to a feature request so people can upvote it. We actually have one like this for the DateTimePicker and I have cast a vote for it on your behalf:

However, it is possible to make the DateTimeOffset properties behave like a date in the grid -  e.g. you can use the columns format instead of template and get the built-in filter menu with date pickers for the column. To do this you should trick the grid by using the model and by specifying the type manually:

 .Model(m=> {
        m.Field("OrderDate", typeof(DateTime));

If you have server operations enabled (they are enabled by default), you will need to "translate" the DateTimeOffset to a date here too, before passing it to the ToDataSourceResult() to execute the query:

public ActionResult Orders_Read([DataSourceRequest] DataSourceRequest request)
            return Json(orders.ToDataSourceResult(request));

        private void ModifyFilters(IEnumerable<IFilterDescriptor> filters)
            if (filters.Any())
                foreach (var filter in filters)
                    var descriptor = filter as FilterDescriptor;
                    if (descriptor != null && descriptor.Member == "OrderDate")
                       // use this if using just dates
                        descriptor.Member = "OrderDate.Date";
                    if (descriptor != null && descriptor.Member == "OrderDateWithMinutes")
                        // use this if time is necessary
                        descriptor.Member = "OrderDateWithMinutes.DateTime";
                    else if (filter is CompositeFilterDescriptor)

Let me know in case you have further questions.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.