jq网格;以 JSON 格式提取的日期未显示在表中.也无法格式化日期

jqGrid; date being fetched in the json format is not being displayed in the table. Not able to format the date either

本文关键字:日期 格式化 显示 JSON 格式 提取 jq 网格      更新时间:2023-09-26

这是我第一次使用jqGrid。表中根本不显示日期。数据以 json 格式编码。在调试时,我发现获取的日期是 unicode(不确定)格式,基本上是一个 13 位数字。我尝试使用srcformat作为"U"或"u"。但两者都不起作用。我尝试创建自定义格式化程序,但这返回了一个未定义的日期。

例如,JSON 值为"1380556800000"。另外,我想提一下java对象是时间戳类型。

如果你能指出我在这里到底做错了什么,那就太好了。提前致谢

function searchSchePtn(){
    var sParam = {
    outPtnId : $('#outPtnId').val(),
    floutScheCd : $('#scheCd').val(),
    floutScheNm : $('#scheNm').val(),
    schePtn : $('#schePtn').val(),
    status : $('#status').val(),
};
var schePtnList = null;
SchePtnAccessor.getFloutSchePtnList(sParam, {
    callback : function(value) {
        schePtnList = JSON.parse(value);
    },
    async : false
});
$('#schePtnList').jqGrid('GridUnload');
$('#schePtnList').jqGrid(
        {
            data : schePtnList,
            datatype : 'local',
            height : 250,
            rowNum : 10,
            rowList : [ 10, 20, 30 ],
            colNames : [ 'Schedule Id', lang.getMessage('出力パターン名称', 'Output Pattern Name'), 'Schedule Code', 'Schedule Name', 'Schedule Pattern', 'Start Date', 'Execution Time', 'Status'],
            colModel : [ {
                name : 'floutScheId',
                index : 'floutScheId',
                hidden : true,
        },{
                name : 'outPtnName',
                index : 'outPtnName',
                width : 150,
                sorttype : "String"
            }, {
                name : 'floutScheCd',
                index : 'floutScheCd',
                width : 150,
                sorttype : "String"
            }, {
                name : 'floutScheNm',
                index : 'floutScheNm',
                width : 150,
                sorttype : "String"
            }, {
                name : 'schePtn',
                index : 'schePtn',
                width : 50,
                sorttype : "String"
            }, {
                name : 'sDate',
                index : 'sDate',
                width : 100,
                formatter: 'date',
                formatoptions: {srcformat:'U', newformat:'d-M-y H:i'}
            } , {
                name : 'actTime',
                index : 'actTime',
                width : 50,
                sorttype : "String"
            }, {
                name : 'status',
                index : 'status',
                width : 50,
                sorttype : "String"
            }],
            pager : '#schePtnListPager',
            viewrecords : true,
            gridview : true,
        });

};

我认为这个问题之前已经回答过了。不确定您是否有同样的问题,但请尝试查看此....JQ网格日期格式

更新

name: 'myDate',
        index: 'myDate',
       align: 'left',
          sortable: true,
          formatter: 'date',
         formatoptions: 
        {srcformat: 'u', newformat: 'd/m/Y H:i:s'},
          width: 70,  

js小提琴