Kendo格式格式时间问题在日期栏 [英] Kendo grid format time issue in date column

查看:212
本文介绍了Kendo格式格式时间问题在日期栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个kendo网格,它有一个日期列。我想在那里显示日期和时间。我在列定义中使用以下格式,



格式:{0:dd-MMM-yyyy hh:mm:ss tt}



在模态中,我使用日期类型 Updated_Date:{type:date} / p>

输出日期为'10 -Oct-2013 12:00:00 AM',但通过ajax通话返回的实际日期为Updated_Date:2013-10- 10T05:02:40.44



如何在Grid中显示正确的时间,如2010年10月10日05:02:40 AM?

解决方案

有两个字段通常被困惑:




  • 格式:指定格式,用于格式化输入中显示的DateTimePicker的值。

  • parseFormats :指定使用的格式解析value()方法或直接输入的值。



所以实际上你需要定义一个parseFormat,因为<日期和时间之间的code> T 使格式不是默认格式:



尝试:

 列:[
...
{
字段:日期,
标题:日期,
格式:{0:dd-MMM-yyyy hh:mm:ss tt},
parseFormats:[yyyy-MM-dd'THH:mm:ss.zz ]
}
]

运行示例:http://jsfiddle.net/OnaBai/Ahq6s/


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,

format: "{0:dd-MMM-yyyy hh:mm:ss tt}"

In modal I used date type Updated_Date: { type: "date" }

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"

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 : 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.

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:

Try:

columns   : [
    ...
    {
        field       : "Date",
        title       : "Date",
        format      : "{0:dd-MMM-yyyy hh:mm:ss tt}",
        parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
    }
]

Running example here : http://jsfiddle.net/OnaBai/Ahq6s/

这篇关于Kendo格式格式时间问题在日期栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆