date renderer issue in extjs
I have a date renderer issue for a column. When browser language is in English the date is displayed in this format
09/14/2009 09:23 AM
But when I change the browser language to German(displays correctly in English and French) the date is not rendered it displays NAN/NAN/NAN 12:NAN PM
Here is the code.
var dateRenderer = Ext.util.Format.dateRende开发者_StackOverflowrer('m/d/Y h:i A');
var colModel = new Ext.grid.ColumnModel([
{
header: xppo.st('SDE_DATE_OCCURRED'),
width: 75,
sortable: true,
dataIndex: 'DateOccurred',
renderer: dateRenderer
}]);
How can I render the date in other languages? Please help me with this issue.
Are you certain that the input date is being parsed correctly for German? The dateRenderer output should be the same -- if it works at all, the language should not matter. Since you are getting NaN it's more likely that something in the input data for German is invalid.
Why dont you use an Ext.grid.DateColumn ? its very simple... simply pass
format: "d.m.Y H:i:s"
to its constructor and everything should be fine :)
I had a similar issue. But it was fixed only when correct dateFormat was set. (Of course data must be passed from server side correctly)
reader: new Ext.data.JsonReader({
root: 'mails',
totalProperty: 'totalCount',
idProperty: 'mail_id',
fields: [
'mail_id',
{name: 'mail_date', type: 'date', dateFormat: 'Y-m-d h:i:s'}
]
}
...
this.columns = [sm,{
header: 'Date',
dataIndex: 'mail_date',
width: 150,
renderer: Ext.util.Format.dateRenderer('d.m.Y H:i:s'),
sortable: true
}];
精彩评论