日期列中的剑道网格格式时间问题 [英] Kendo grid format time issue in date column
问题描述
我有一个剑道网格,它有一个日期列.我想在那里显示日期和时间.我在列定义中使用以下格式,
I have a kendo grid, it has a date column. I want to show date and time there. I am using below format in column definition,
格式:{0:dd-MMM-yyyy hh:mm:ss tt}"
在模态中我使用了日期类型 Updated_Date: { type: "date" }
In modal I used date type Updated_Date: { type: "date" }
输出日期是 '10-Oct-2013 12:00:00 AM',但通过 ajax 调用返回的实际日期是 "Updated_Date":"2013-10-10T05:02:40.44"
Output date is coming as '10-Oct-2013 12:00:00 AM', but actual date returned via ajax call is "Updated_Date":"2013-10-10T05:02:40.44"
如何在 Grid 中显示正确的时间,例如 10-Oct-2013 05:02:40 AM?
What to do to show the correct time in Grid like 10-Oct-2013 05:02:40 AM?
推荐答案
有两个领域经常被混淆:
There are two fields that are commonly confused:
- format :指定格式,用于格式化显示的DateTimePicker的值在输入中.
- parseFormats:指定格式,用于解析用value() 方法或直接输入.
- format : Specifies the format, which is used to format the value of the DateTimePicker displayed in the input.
- parseFormats: Specifies the formats, which are used to parse the value set with value() method or by direct input.
所以实际上你需要定义一个 parseFormat 因为日期和时间之间的 T
使得格式不是默认格式:
So actually you need to define a parseFormat because of the T
between date and time that makes the format not being a default one:
试试:
columns : [
...
{
field : "Date",
title : "Date",
format : "{0:dd-MMM-yyyy hh:mm:ss tt}",
parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
}
]
在此处运行示例:http://jsfiddle.net/OnaBai/Ahq6s/
这篇关于日期列中的剑道网格格式时间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!