剑道网格日期列未格式化 [英] Kendo grid date column not formatting

查看:17
本文介绍了剑道网格日期列未格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像下面这样的 KendoGrid,当我运行应用程序时,我没有得到 date 列的预期格式.

I have a KendoGrid like below and when I run the application, I'm not getting the expected format for date column.

$("#empGrid").kendoGrid({
    dataSource: {
        data: empModel.Value,
        pageSize: 10
    },

    columns: [
        {
            field: "Name",
            width: 90,
            title: "Name"
        },

        {
            field: "DOJ",
            width: 90,
            title: "DOJ",
            type: "date",
            format:"{0:MM-dd-yyyy}" 
        }
    ]
});

运行此程序时,我在 DOJ 列中收到2013-07-02T00:00:00Z".为什么不格式化?有什么想法吗?

When I run this, I'm getting "2013-07-02T00:00:00Z" in DOJ column. Why it is not formatting? Any idea?

推荐答案

我找到了这条信息并使其正常工作.给我的数据是字符串格式,所以我需要在使用 kendo.toString 格式化之前使用 kendo.parseDate 解析字符串.

I found this piece of information and got it to work correctly. The data given to me was in string format so I needed to parse the string using kendo.parseDate before formatting it with kendo.toString.

columns: [
    {
        field: "FirstName",
        title: "FIRST NAME"
    },
    {
        field: "LastName",
        title: "LAST NAME"
    },
    {
        field: "DateOfBirth",
        title: "DATE OF BIRTH",
        template: "#= kendo.toString(kendo.parseDate(DateOfBirth, 'yyyy-MM-dd'), 'MM/dd/yyyy') #"
    },
...

<小时>参考资料:

  1. 格式-网格日期
  2. jsfiddle
  3. kendo ui 日期格式

这篇关于剑道网格日期列未格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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