PDA

View Full Version : Ext.data.Record.create() and new records



Kupuyc
19 Mar 2011, 5:57 AM
Hi. I have problem with understanding what I do wrong. I define new record type, for example:

var someDocumentRecord = Ext.data.Record.create([{
name: 'documentID',
type: 'int'
}, {
dateFormat: 'Y-m-d H:i:s',
name: 'createDate',
type: 'date'
}]);

I try to create new record:


var record = new someDocumentRecord({documentID: "1", createDate: "2011-02-28 23:49:26"})

and record.get('documentID') is string, but not int and record.get('createDate') is string too. Seems like Ext.data.Field converter does not work.

fay
19 Mar 2011, 6:25 AM
Try the following:



var someDocumentRecord = Ext.data.Record.create([
{
name: 'documentID',
type: 'int'
},
{
dateFormat: 'Y-m-d H:i:s',
name: 'createDate',
type: 'date'
}
]);

var record = new someDocumentRecord({documentID: 1, createDate: new Date('2011-02-28T11:49:26')});
console.log(record.get('createDate'));

Kupuyc
19 Mar 2011, 6:59 AM
Thank you for your reply.

I can't - data was recieved from server by ajax.

The primary problem is that in many places used notation like someRecord.get ('someField'). Therefore, received JSON data I need to wrap by Ext.data.Record.