The background retrieves the time from the database, formats it in JSON and then transmits it to the gridpanel. At this time, the time becomes: /Date(32331121223)/. Then the following processing is required to display it normally:
in
var record = Ext.data.Record.create([
{ name: 'PublicDate', mapping: 'PublicDate', dateFormat: 'Y-m-d', convert: function (v) {
if (v == null) {
return null;
}
var d = new Date();
var str = v.toString();
var str1 = str.replace("/Date(", "");
var str2 = str1. replace(")/", "");
var dd = parseInt(str2);
d.setTime(dd);
return d;
} }
]);
Then copy the code in:
var cm = new Ext.grid.ColumnModel([
{ header: 'Publication time', dataIndex: 'PublicDate', width: 120, align: 'center', renderer: Ext.util.Format.dateRenderer('Y-m- d') }
]);
This will display normally, such as: 2012-11-19,