PDA

View Full Version : Ext.data.Model.get("MyField") throwing error due to undefined data



FBNitro
24 Apr 2015, 1:35 PM
I'm coming from Sencha Touch 2.4.x.

Not sure exactly what's going on here, but I have a record that gets populated in memory via a json reader. After it's populated I'm seeing something inconsistent...

My model is defined as:

Ext.define('MyModel', {
extend: 'Ext.data.Model',
idProperty: 'MyID',
fields: value, //Value is an array of fields
});

My proxy is:

Ext.create('Ext.data.proxy.Memory', {
config: {
model: 'MyModel',
reader: {
type: 'json'
}
}
});

My read looks like this:

myRecord = myRecord.getProxy().getReader().read(response).getRecords()[0];

^^^ this line throws a deprecated error:
""Ext.data.Model#persistenceProperty" is deprecated."

myRecord.get("FieldName") throws an exception (because data is undefined)
myRecord.FieldName gives me the value I expect.

I would expect both these calls to return the same thing. Maybe I'm going about this the wrong way. I'm open to responses.

Additional, slightly off topic note: Previously I could pass in response.responseText to the .read() function, but I've found that does not work anymore, I have to pass in the entire response. It doesn't seem to like the json String.

mitchellsimoens
25 Apr 2015, 4:17 PM
Why are you creating a record like that? Why not use Ext.create to create the record? If you are using an Ajax call, the set a proxy on the model and use the static load method on the model call.

incutonez
14 Aug 2015, 1:42 PM
Any update on this? I was getting this error when trying to do a custom sort (https://ee-origin.sencha.com/forum/showthread.php?304125-Internet-Explorer-custom-column-sort-issue)... but the error only showed in Internet Explorer.