Sab*_*ish 5 sorting formatting date jqgrid
我需要以两种格式显示日期,例如mm/dd/yyyy和mm/dd/yyyy hh:mm:ss.我发现我们可以在colmodel中使用formatoptions
formatoptions: {srcformat: 'ISO8601Long', newformat: 'm/d/y'}
Run Code Online (Sandbox Code Playgroud)
和
formatoptions: {srcformat: 'ISO8601Long', newformat: 'm/d/y h:i:s'}
Run Code Online (Sandbox Code Playgroud)
但我得到jqgrid的输出为mm/dd/yy.任何人都应该给出解决方案如何显示mm/dd/yyyy.我需要对两个列进行排序.
提前致谢
您可以使用"Y"代替"y"将年份显示为"yyyy"而不是"yy":
formatter:'date', formatoptions: {srcformat:'ISO8601Long', newformat:'m/d/Y H:i:s'}
Run Code Online (Sandbox Code Playgroud)
如果你想在mounth和tha da中没有前面的空值(没有0填充),你可以使用'n/j/Y'而不是'm/d/Y'.您可以在格式化程序的源代码中找到"日期"格式化程序支持的所有不同可能标志.
修订版:问题是,所述的短名称srcformat等ISO8601Long,UniversalSortableDateTime,ShortDate等等(参见文档的详细信息)可以与仅用于远程网格数据(datatype:'json'或datatype:xml).为了使本地排序工作,纠正你应该使用的,而不是srcformat:'ISO8601Long'来srcformat:'Y-m-d H:i:s'.
该演示表明,此类更改将使本地排序工作正确.
我认为限制srcformat可以解释为jqGrid中的错误.所以我建议你在trirand论坛上发布相应的bug报告.然后Tony Tomov(jqGrid的开发者)可以在jqGrid代码中进行相应的更改.