Reputation: 992
I am trying to show a datetime column appropriately in my Kendo UI Grid. Date is being shown successfully, but not time. Here's a simple jsfiddle showing my scenario.
field: "Date",
title: "Date",
format: "{0:dd-MMM-yyyy hh:mm:ss tt}",
parseFormats: ["MM/dd/yyyy h:mm:ss"]
I have tried different alternatives with no success. Any thoughts on how to show the content as expected would be greatly appreciated!
Upvotes: 4
Views: 37512
Reputation: 49
columns.Bound(date=> date.START_DATE).Title("Start Date").Format("{0:MM dd, yyyy}");
Upvotes: 0
Reputation: 4102
Use template:
{
field: "Date"
, title: "Date"
, width: "100px"
, template: "#= (Date == null)? '' : kendo.toString(kendo.parseDate(Date, 'yyyy-MM-dd'), 'MM/dd/yy') #"
},
Upvotes: 10
Reputation: 127
datatype you specified for date field is date type.it should be datetime as shown in the below
fields: {
Id: { type: 'number' },
FirstName: { type: 'string' },
LastName : { type: 'string' },
Date: { type: 'datetime' }
}
Upvotes: 3
Reputation: 894
I got it working based on your fiddle: jsfiddle. I modified the object definition slightly and kept the "date" data type:
{
field : "Date",
title : "Date",
format : "{0:dd-MMM-yyyy hh:mm:ss tt}",
parseFormats: ["MM/dd/yyyy h:mm:ss"],
filterable: {
ui: "datetimepicker"
}
}
Hope this helps. Good luck.
Upvotes: 2