ExtJs gridpanel displays date type data returned by Java

Background Java returns time object format:
"lastLoginTime":{"date":4,"day":3,"hours":12,"minutes":0,"month":6,"seconds":0,
   "time ":1341374400000,"timezoneOffset":-480,"year":112}

Foreground processing: Processing
in ColumnModel:
{header: "Last login time", sortable: true,
      renderer : Ext.util.Format.dateRenderer('Ymd H :i:s') ,
      dataIndex: 'lastLoginTime'}

processed in JsonStore (note the bolded part):
fields : ['depId','depName',{
name:'lastLoginTime',
type:'date',
mapping : ' lastLoginTime.time',
dateFormat : 'time'

},'mail','password',' phone', 'status', 'userId', 'userName']
also need to pay attention, the fields must be matched in sequence, if there is no special processing time, it is not needed, now after the special processing time, adding mapping, the others do not know How does it correspond, so the default is to follow the returned json order, which should be corresponding here.

But when the Date returned by Java is NULL, you will find that the GridPanel does not display the data at all. The solution is as follows (using convert):

Processing in JsonStore:
fields : ['depId','depName',{
name:'lastLoginTime ',
type:'date',
mapping : 'lastLoginTime',
convert : function(v,f){
if(v == null){
return '';
}
var dt = new Date();
dt.setTime(v. time);
return Ext.util.Format.date(dt,'Ymd H:i:s');
},
// mapping : 'lastLoginTime.time',
dateFormat : 'time',
defaultValue : ''
},'mail ','password','phone','status','userId', 'userName']
and ColumModel does not need special processing, as follows:

{header: "Last Login Time", sortable: true, dataIndex: 'lastLoginTime'}



Content source: http://chamcon.iteye.com/blog/1577291, please support the author.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325815449&siteId=291194637