0

我的格式选项被忽略:

{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 模块?

4

1 回答 1

1

属性srcformatnewformat是格式化程序的选项。因此,您应该遵循文档并将列定义重写为

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

顺便说一下 jqGrid 不知道edittype: 'date'。请参阅文档。格式mm-dd-yyyy不是 ISO8601 日期格式。正确的 ISO8601 格式是yyyy-mm-dd. 我希望服务器使用 JSON 响应中的格式。

于 2013-06-26T18:48:17.177 回答