【问题标题】:jqGrid: format options being ignoredjqGrid:格式选项被忽略
【发布时间】:2013-06-26 18:25:23
【问题描述】:

我的格式选项被忽略了:

{name:'effectiveDate', 
        width:'80',  
        align: 'center',
        editable:true, 
        formatter: 'date',
        srcformat:'ISO8601Short',
        newformat: 'Y-m-d', 
        edittype:'date', 
        editrules:{
        required:true
               }
}

后端以 mm-dd-yyyy 格式发送 json 日期。它们被 jqGrid 正确解析,值正确并以 m/d/y 格式显示在网格中,但我无法更改格式,无论我为“newformat”输入什么,即使我输入垃圾它也会忽略它并始终显示 m/d/y。可能是我缺少 Formatter 模块,还是有其他解释?如何验证我是否有 Formatter 模块?

【问题讨论】:

    标签: jqgrid


    【解决方案1】:

    属性srcformatnewformat 是格式化程序的选项。所以你应该关注the documentation并将列定义重写为

    {
        name:'effectiveDate', 
        width: 80,  
        align: 'center',
        editable: true, 
        formatter: 'date',
        formatoptions: {
            srcformat:'ISO8601Short',
            newformat: 'Y-m-d', 
        },
        editrules: {
            required:true
        }
    }
    

    顺便说一句,jqGrid 不知道edittype: 'date'。见the documentationmm-dd-yyyy 格式不是 ISO8601 日期格式。正确的 ISO8601 格式是 yyyy-mm-dd。我希望服务器使用 JSON 响应中的格式。

    【讨论】:

    • 谢谢 Oleg,抱歉,我显然没有对文档给予足够的重视。接下来,我将通过修改语言文件来查看全局覆盖日期格式,以便使用“d-MMM-Y”(例如 2010 年 4 月 23 日)。如果我遇到困难,我会发布另一个问题。
    猜你喜欢
    • 1970-01-01
    • 2020-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 1970-01-01
    • 2012-08-01
    • 2015-05-04
    相关资源
    最近更新 更多