KendoUI格式化日期和时间字段

imp*_*335 8 jquery kendo-ui kendo-grid

我试图将以前仅限日期的字段转换为日期时间字段,但它不起作用.

我有:

schema: {
    model: {
    id: 'id',
    fields: {
        dateCreated: {
        type: "date", format: "{0:yyyy/MM/dd HH:mm}", editable: "false"
        },
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用,日期格式正确,但时间最终为00:00.

如果我将字段类型更改为"字符串",则数据显示正确,但格式化为SQL方式,即:

2012-05-11 12:56:29
Run Code Online (Sandbox Code Playgroud)

没有"datetime"这样的字段类型,只有"date".如何让它输出我想要的?即:

11/05/2012 12:56
Run Code Online (Sandbox Code Playgroud)

有人有主意吗?

nap*_*nss 20

您必须使用模板 '#= kendo.toString(kendo.parseDate(dateCreated), 'MM/dd/yyyy HH:mm tt')#'


Vto*_*one 8

你在哪里尝试使用这些数据?如果您在网格中使用它,则可以在列定义中使用"template"属性

var columnDefinition = [
    {
        field: "dateCreated",
        title: "Created",
        template: "#= kendo.toString(dateCreated,'MM/dd/yyyy HH:mm tt') #"
    }
];
Run Code Online (Sandbox Code Playgroud)

这是网格格式的小提琴