JQgrid使用特定格式在客户端排序日期 [英] JQgrid Sorting date on the client side with a specific format

查看:113
本文介绍了JQgrid使用特定格式在客户端排序日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQGrid来存储客户端本身加载的数据。
我想按照自定义格式排序日期(即2010年11月11日)。我想在客户端排序(由于要求)。任何人都可以向我建议我需要做什么?



感谢提前!



With Regards

Phani Kumar

解决方案

jqGrid支持日期格式化程序。它可以在您希望的格式中在网格中显示日期。您只需要选择相应的格式化程序选项,如

  sorttype:'date',formatter:'date',formatoptions:{newformat :'dM-Y'} 

所以你可以用一种格式填充网格(默认格式为ISO日期格式Ymd,我建议您使用此格式)。您也可以使用 Date 类型作为本地数据的输入。选项 newformat 定义用户将显示的数据格式。在内部,日期将被保留并排序为 Date JavaScript类型。



为了使使用实际上很容易以上解释,我创建了一个小型的演示示例,您可以看到现场和考试JavaScript代码。


I am using JQGrid to store the data which is being loaded on the client side itself. I want sort the date which is in a customized format(i.e. 11-Nov-2010). I want to sort it on the client side (due to the requirement). Can anyone of you suggest me what I need to do?

Thanks in Advance!

With Regards

Phani Kumar

解决方案

jqGrid support date formatter. It allows to display the date in the grid in the format which you prefer. You need only the choose the corresponding formatter option like

sorttype:'date', formatter:'date', formatoptions: {newformat:'d-M-Y'}

So you can fill the grid in one format (default format form is ISO Date format Y-m-d and I recommend you to use this format). You can also use Date type as input for the local data. The option newformat define the format of data which will be displayed for the user. Internally the date will be hold and sorted as the Date JavaScript type.

To make easy to use practically what I explained above I created small demo example which you can see live and examin it's JavaScript code.

这篇关于JQgrid使用特定格式在客户端排序日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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