Kendo 网格日期输入输出无法正常工作

Kendo Grid Date Input Output not properly working

我正在处理以下示例:http://dojo.telerik.com/InEyo

在此示例中,我将数据输入的日期设置为

var date = "2013-10-10 14:02:40.44";

要读取日期,我在定义日期列的位置使用以下内容:

format: "{0:dd-MMM-yyyy HH:mm:ss}",
parseFormats: ["yyyy-MM-dd' 'HH:mm:ss.zz"]

parseFormats 定义了输入字符串的格式,格式定义了我想如何显示它(据我所知)。我的例子来自 Kendo grid format time issue in date column

上面的示例有效 - 应该如此!

我的问题(http://dojo.telerik.com/aqafE):我从数据库中获取的日期格式如下: “20131010 140240”- 所以 "yyyyMMdd HHmmss".

自然我会像这样调整 parseFormats:

format: "{0:dd-MMM-yyyy HH:mm:ss}",
parseFormats: ["yyyyMMdd' 'HHmmss"]

但是这不会输出日期,所以我假设我在定义输入字符串时犯了错误,或者数据库中的字符串不适用于 Kendo...

有什么想法吗?谢谢

在您的示例中,您需要做的就是更改数据源模式定义模型的方式,而不是尝试在网格列上进行。

所以从这里开始:

schema: {
    model: {
        fields: {
            Id       : { type: 'number' },
            FirstName: { type: 'string' },
            LastName : { type: 'string' },
            Date: { type: 'date'},
        }
    }
}

为此:

schema: {
    model: {
        fields: {
            Id       : { type: 'number' },
            FirstName: { type: 'string' },
            LastName : { type: 'string' },
            Date     : { type: 'date',
                         parse: function(date) {
                             return kendo.parseDate(date,"yyyyMMdd HHmmss");
                         }
                       }
        }
    }
}

编辑:这是 fiddle link:http://dojo.telerik.com/aqafE/3