Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Last active December 20, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmilfont/6106484 to your computer and use it in GitHub Desktop.
Save cmilfont/6106484 to your computer and use it in GitHub Desktop.
Override do Ext.data.Model para dar suporte ao mapping de seus Fields durante o Ext.create.
Ext.override(Ext.data.Model, {
constructor: function() {
this.callParent(arguments);
this.fields.each(function(field){
if( field.mapping && this.get( field.name ) == "") {
this.set( field.name,
function(property, raw) {
return property.split(".").reduce(function(object, name){
if(object && name) return object[name];
}, raw);
}(field.mapping, this.raw)
);
}
}, this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment