JSON数据返回的一行的数据如下 :两种情况
(1)
{"comm":0,"empno":7876,"ename":"ADAMS","hiredate":"1998-12-12 08:25:36","job":"CLERK","mgr":7788,"sal":1100}
(2)
{"comm":0,"empno":7876,"ename":"ADAMS","hiredate":{"date":12,"day":6,"hours":8,"minutes":25,"month":11,"nanos":0,"seconds":36,"time":913422336000,"timezoneOffset":-480,"year":98}
JSonReader中读取pubdate属性的设置代码如下:
var myreader=new Ext.data.JsonReader({
idProperty: 'empno',
root:'data',
totalProperty: 'total',
fields: [
{name: 'empno'},
{name: 'ename'},
(1) {name: 'hiredate',type:'date',dateFormat :'Y-m-d H:i:s'}
(2)// {name: 'hiredate',mapping:'hiredate.time',type:'date',dateFormat:'time'}
]
});
reader中的dateFormat格式对应从后台传过来点格式。下面在grid中显示列中则可以随便你怎么格式
Grid的columnmodel设置如下:
function formatDate(value){
return value ? value.dateFormat('Y-m-d') : '';
}
{
// xtype:'datecolumn',
// format:'Y-m-d h:i:s',
header : 'hiredate',
width : 200,
sortable : true,
dataIndex: 'hiredate',
renderer:formatDate,
// renderer:Ext.util.Format.dateRenderer('Y-m-d'),
editor: new fm.DateField({
// allowBlank: false
})
}
注释的都是可以随便显示
alert(Ext.util.Format.date(name,'Y-m-d'));