伙计们我正在使用jqgrid并且我有一个日期从这样的json对象获取数据..
var data = {
"rows":[
{"OrderID":"10248","Date":"1996-07-04","time":"16:22","ShipName":"Vins et alcools","CustomerID":"WILMK"},
{"OrderID":"10249","Date":"1996-07-05","time":"17:00","ShipName":"Toms Spezialit\u00e4ten","CustomerID":"TRADH"},
{"OrderID":"10250","Date":"1996-07-08","time":"17:09","ShipName":"Hanari Carnes","CustomerID":"HANAR"},
]}

我在jsp文件中将其定义为
{ label: 'Date', name: 'Date', width: 150 ,
editable: true,
edittype:"text",
editoptions: {
autoclose: true,
autoOpen: false,
format: 'yyyy-mm-dd',
orientation : 'auto bottom',
dataInit : function (elem) {
setTimeout(function(){
$(elem).datepicker({ showOn: 'focus' });
},10);
},
},
},
所以例如日期是1996-07-04
,当我编辑它时它会给我05/30/1904
..任何帮助??
答案 0 :(得分:0)
问题是您在列模型中没有formatter =“date”,而且您在网格中指定的任何格式都没有意义。它在非编辑中起作用的原因是因为它假定它是一个字符串,它将它放在json中。
修复将是
将格式化程序和formatoptions添加到列模型,将dateFormat添加到日期选择器,如下所示
{ label: 'Date',
name: 'Date',
width: 150 ,
editable: true,
edittype:"text",
// add the two lines below
formatter: "date",
formatoptions: { newformat: "yyyy-mm-dd" },
editoptions: {
autoclose: true,
autoOpen: false,
// format: 'yyyy-mm-dd', Commented it no need
orientation : 'auto bottom',
dataInit : function (elem) {
setTimeout(function(){
$(elem).datepicker({ showOn: 'focus',
dateFormat: 'yyyy-mm-dd' });
},10);}, },
},