jqgrid datetime列以24小时格式排序

时间:2011-03-11 20:46:31

标签: json datetime jqgrid

我在spring MVC中使用json对象,使用json reader来填充jqgrid。

{
    "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" 
        } 
    ]
}

我需要对

进行排序
  

开始时间

列以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});
});

1 个答案:

答案 0 :(得分:4)

当我尝试重现你的问题时,一切似乎都正常。现场观看演示here。如果您按“开始时间”列排序,所有工作都没有任何问题,我可以看到。