jqGrid - date&时间格式未被应用 [英] jqGrid - date & time format not being applied

查看:740
本文介绍了jqGrid - date&时间格式未被应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqGrid显示3列,其中之一是日期时间(正在返回的SQL日期时间字段)。 colModel设置如下:

  colModel:[
{name:col1,....,sortable: false},
{name:col2,....,sortable:false},
{name:SendTime,index:SendTime,width:col3width,align:left ,formatter:datetime,formatoptions:{srcformat:ISO8601Long,newformatLongTime},xmlmap:SendTime,sortable:false}
],

从SQL返回的日期格式如下:

  YYYY-MM-DDTHH:mm:ss 

jqGrid将被排序,并且SQL ORDER BY 控制正在返回的数据的顺序。



我想更改返回的日期格式以省略其中间的T - YYYY-MM-DD HH:mm:ss 。如果我不能这样做,我会考虑只有格式化的军事时间。我在colModel设置中尝试了几种格式选项,但是只能成功格式化日期或时间,但不能同时使用。



这是否需要自定义格式化程序,还是我忽略jqGrid中的设置?感谢任何帮助。



谢谢!
S

解决方案

jqGrid已预定义格式化程序:date,但没有格式化程序:datetime(请参阅文档)。所以你应该修改格式化程序的名称使其工作。



最后一个版本的jqGrid支持 YYYY-MM-DDTHH:mm:ss 而不仅仅是 YYYY-MM-DD HH:mm:ss 。所以您不需要对后端进行任何更改。



您应考虑使用 sorttype:date而不是。如果您使用 loadonce:true 或者使用数据类型:local


I have a jqGrid that displays 3 columns, one of which is a date-time (SQL Datetime field that is being returned). The colModel settings follow:

               colModel:[
            {name:"col1",....,sortable:false},
            {name:"col2",....,sortable:false},
            {name:"SendTime",index:"SendTime",width:col3width,align:"left",formatter:"datetime",formatoptions:{srcformat:"ISO8601Long",newformat:"LongTime"},xmlmap:"SendTime",sortable:false}
            ],

The date that is being returned from SQL is in the following format:

YYYY-MM-DDTHH:mm:ss

None of the fields in the jqGrid will be sortable, and the SQL ORDER BY controls the order of the data being returned.

I would like to change the date format that is being returned to omit the "T" in the middle of it - YYYY-MM-DD HH:mm:ss. If I can't do that, I would consider just having the formatted military time. I've tried several format options in the colModel settings, but have only succeeded in formatting the date or the time, but not both at once.

Does this require a custom formatter, or am I overlooking settings in jqGrid? Would appreciate any help.

Thanks! S

解决方案

jqGrid have predefined formatter:"date", but no formatter:"datetime" (see the documentation). So you should fix the name of formatter to make it working.

The last version of jqGrid supports YYYY-MM-DDTHH:mm:ss and not only YYYY-MM-DD HH:mm:ss. So you don't need to make any changes on the backend.

You should consider to use sorttype: "date" instead. It could be helpful if you use loadonce: true or if you use datatype: "local".

这篇关于jqGrid - date&时间格式未被应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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