Skip to content

Instantly share code, notes, and snippets.

@jratcliff
Last active April 24, 2018 20:35
Show Gist options
  • Save jratcliff/b3ec3a4c5fe4f5aabf7f3b9c9a792ecc to your computer and use it in GitHub Desktop.
Save jratcliff/b3ec3a4c5fe4f5aabf7f3b9c9a792ecc to your computer and use it in GitHub Desktop.
overrides for Ext.data.reader.Json
Ext.define('overrides.data.Reader.Json', {
override: 'Ext.data.reader.Json',
/**
* Override that makes sure to first delete the existing store so that keyless associations
* can be reloaded when their parent record is reloaded.
* JIRA: EXTJS-21175
*/
readAssociated: function(record, data, readOptions) {
var roles = record.associations,
key, role;
for (key in roles) {
if (roles.hasOwnProperty(key)) {
role = roles[key];
if (role.cls) {
// override begin
// delete the existing store since we are reading in new data
if (Ext.getVersion('extjs').isLessThan('6.5') && record[role.storeName]) {
delete record[role.storeName];
}
// override end
role.read(record, data, this, readOptions);
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment