PDA

View Full Version : problem when rendering date



MmarcoM
3 Sep 2009, 12:56 PM
hello all
i m having huge problems when trying to render a date into my grid.
it's always getting rendered as NaN...
here's my json response


[{"id": "1","description": "description1","provisionAmount": "1.0","user": "user1","provisionType": "HOUSE_INSURANCE","provisionDate": "Thu Sep 03 21:53:17 BST 2009"}]

here's my extjs code (i have tried every possible renderer)


var dsProvisions = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({url: '../provision-data/LoadProvisions.do'}),
root:'model.provisionList',
id:'id',
fields:
[ {name: 'id' , mapping:'id'},
{name: 'description', mapping: 'description'},
{name: 'provisionType', mapping: 'provisionType'},
{name: 'provisionAmount' , mapping:'provisionAmount'},
{name: 'provisionDate', mapping:'provisionDate'},
{name: 'username' , mapping:'user'}]
});

var cmProvisions = new Ext.grid.ColumnModel([
{header: 'Id', type:'long',width: 80, sortable: true, dataIndex: 'id'},
{header: 'Description', type:'string',width: 120, sortable: true, dataIndex: 'description'},
{header: 'Type', type:'string',width: 120, sortable: true, dataIndex: 'provisionType'},
{header: 'Amount', type:'double', width: 90, sortable: true, dataIndex: 'provisionAmount'},
{header: 'Date', type:'string', width: 90, sortable: true, dataIndex: 'provisionDate', renderer:formatDate},
{header: 'User', type:'string', width: 90, sortable: true, dataIndex: 'username'},

]);

function formatDate(value){

alert('date is:' + value);
var newValue = Ext.util.Format.date(value);
alert('new value is:' + newValue);
return Ext.util.Format.date(value, 'd-m-Y H:i:s');
}


In the format date, the first alert is fine but the second always return NaN......

anyone could help?

regards
marco