PDA

View Full Version : JsonReader and recordType is undefined



pouli
6 Oct 2010, 7:43 AM
Hello,

I am trying to do my first JsonStore to work but I keep receiving: recordType is undefined.
Here is the the interesting part:

var TestRecord = Ext.data.Record.create([ // creates a subclass of Ext.data.Record
{name: 'lanID'},
{name: 'translation'}
]);

var writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields : true
});

var reader = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
root: 'data',
idProperty: 'lanID'
},
TestRecord);

var proxy = new Ext.data.HttpProxy({
api: {
read : '/ajax/remote?doAction=AJAX_saveAdditionalRemark&action=read',
create : '/ajax/remote?doAction=AJAX_saveAdditionalRemark&action=create',
update: '/ajax/remote?doAction=AJAX_saveAdditionalRemark&action=update',
destroy: '/ajax/remote?doAction=AJAX_saveAdditionalRemark&action=destroy'
}
});

var propertyStore = new Ext.data.JsonStore({
id: 'user',
autoLoad: false,
proxy: proxy,
writer: writer,
reader: reader,
autoSave: false
});

propertyStore.load();

When I execute this I can see form the firebug that the
"var s = this.meta, Record = this.recordType,"

Record is undefined. Although I specify the type at the reader and I have tried specify the fields at the store with no success.

Any help would be appreciated.
Thank you

Condor
7 Oct 2010, 1:22 AM
JsonStore doesn't have a 'reader' config option. You should use a normal Store instead.

pouli
7 Oct 2010, 1:26 AM
Hello Condor,

yes I have found a way around this by using metadata form the server.
Your post explains better to me why jsonstore was not working with my reader.
It is interesting though that there is no error message when I try to set my reader.

Thank you again for the explanation I will take this into account for similar future problems that I may encounter.