这是我第一次使用 jqGrid。日期根本没有显示在表格中。数据以json格式编码。在调试时,我发现获取的日期是 unicode(不确定)格式,基本上是一个 13 位数字。 我尝试过使用 srcformat 作为“U”或“u”。但两者都不起作用。我尝试创建自定义格式化程序,但返回未定义的日期。
例如,JSON 值为“1380556800000”。另外,我想提一下,java 对象是 Timestamp 类型。
如果您能指出我在这里到底做错了什么,那就太好了。 提前致谢
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,
});
};
最佳答案
我认为这个问题之前已经得到解答...不确定您是否有同样的问题,但请尝试看看这个... jqgrid date formatting
Updated
name: 'myDate',
index: 'myDate',
align: 'left',
sortable: true,
formatter: 'date',
formatoptions:
{srcformat: 'u', newformat: 'd/m/Y H:i:s'},
width: 70,
关于javascript - jqGrid;以 json 格式获取的日期未显示在表中。也无法格式化日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19973464/