我使用json对象,如下所示从spring MVC通过使用json reader来填充jqgrid。jqgrid datetime 24小时排序格式
{
"rows": [
{
"id": 1,
"startTime": "Mar 4 08:00",
"projectId": "Proj_001",
"customerId": "Cust1",
"divisionId": "Div1"
},
{
"id": 2,
"startTime": "Mar 5 15:00",
"projectId": "Proj_001",
"customerId": "Cust1",
"divisionId": "Div1"
},
{
"id": 3,
"startTime": "Apr 14 22:00",
"projectId": "Proj_001",
"customerId": "Cust1",
"divisionId": "Div1"
}
]
}
我需要将
STARTTIME排序其中进来24小时时间格式(如上面在JSON对象)
柱。我试着做一些解决方法,但仍然无法成功。
的jqGrid代码 -
{name:'startTime', index:'startTime', width:90,align:"left",sorttype:'datetime',datefmt:'M d, Y at h:i',sortable: true,editrules:{date:true} },
我将不使用AM/PM符号这里
。我在jqgrid.base.js中看到它使用AM/PM符号进行排序。任何人都可以请解释一下这个?我无法找到任何jqgrid的例子,用24小时的时间格式来排序。先谢谢你。
我的jqGrid代码 -
jq(function(){
jq("#testgrid").jqGrid({
url:"/getall.html",
datatype: 'json',
mtype: 'GET',
colNames:['Id','Start Time','Cust.Id','Div.Id','Proj.Id'],
colModel :[
{name:'id', index:'id', width:90,align:"left",hidden: true},
{name:'startTime', index:'startTime', width:90, align:"left",
sorttype:'datetime', datefmt:'M d h:i',sortable: true,
editrules:{date:true}},
{name:'divisionId', index:'divisionId', width:100,align:"left"},
{name:'departmentId', index:'departmentId', width:120,align:"left"},
{name:'projectId', index:'projectId', width:100,align:"left"},
],
pager: '#testpager',
loadonce: true,
sortname: 'projectId',
sortorder: 'asc',
viewrecords: true,
multiselect: true,
//to hide pager buttons
pgbuttons:false,
recordtext:'',
pgtext:'',
gridview: true,
caption: 'my JQGRID',
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
cell: "cell",
id: "id"
}
});
//toolbar search
//jq("#testgrid").jqGrid('filterToolbar',
// {stringResult:true,searchOnEnter:false});
});
你可以包括(修改和附加问题的文本)jqGrid的完整定义。如果可能的话,我建议你在JSON数据中只使用标准的ISO日期格式(如2011-03-25),并在'formatoptions'中使用'formatter:'date''和'newformat'来转换应该显示的格式。 – Oleg 2011-03-11 21:52:06
我已经使用'datefmt:'M d h:i'',现在它已正确排序。但是当json为'startTime'元素返回'null'时,它将不会正确排序。所以问题还没有100%解决。 – Sam 2011-03-11 21:53:01
如果你发现了一个bug,你应该在这里发布它(http://www.trirand.com/blog/?page_id=393/bugs/)。我建议您在错误报告中插入完整的JavaScript代码和可用于重现问题的测试数据。您只发布了“startTime”列定义的一行,为了重现您的问题,您必须编写一些代码,而这些代码只需花费时间。 – Oleg 2011-03-11 22:18:16