在jqGrid中格式化时间 [英] Format time in jqGrid
问题描述
我正在尝试在jqGrid中设置时间格式.这是行不通的.我想在语言环境文件中使用预定义的格式化程序. col的定义方式如下:
I'm trying to set format for time in a jqGrid. It does not work. I would like to use the predefined formatter in the locale-file. This is how the col is defined:
{ name: 'Tid', index: 'Tid', width: 65, editable: true, formatoptions: { mask: 'ShortTime' }, editrules: { time: true} }
我尝试了几种不同的替代方法,但是在网格上似乎没有什么不同.
I have tried a few different alternatives, but it does not seem to make a differnce in the grid.
推荐答案
在我看来,文档不够清楚.正确的语法应该是
The documentation seems to me not clear enough. The correct syntax should be
formatoptions: { srcformat: 'ISO8601Long', newformat: 'ShortTime' }
其他问题是:$.jgrid.formatter.date.srcformat
(在grid.locale-en.js
中)定义的srcformat
的默认值:'Y-m-d'.因此,默认情况下,将忽略输入数据中的任何时间信息.
Additional problem is: default value of srcformat
defined in $.jgrid.formatter.date.srcformat
(in grid.locale-en.js
): 'Y-m-d'. So any time information from the input data will be ignored by default.
请参见演示.
如果要在网格中使用本地数据,还应该考虑我报告的错误已修复,但它是在发布jqGrid 4.3之后.1.
If you want use local data in the grid, you should additionally take in the consideration the bug which I reported here. The bug is fixed in the code on the github, but it was after publishing of jqGrid 4.3.1.
这篇关于在jqGrid中格式化时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!