Skip to content

Instantly share code, notes, and snippets.

@cmilfont
Created August 2, 2013 23:15
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/6144216 to your computer and use it in GitHub Desktop.
Save cmilfont/6144216 to your computer and use it in GitHub Desktop.
Test before and after overriding in https://gist.github.com/cmilfont/6142566
Ext.define('Atlas.model.Chamado', {
extend: 'Ext.data.Model',
fields: [
'id',
'titulo',
{ name: "status", persist: false, mapping: 'status.nome'},
],
belongsTo: [
{model: 'Atlas.model.Contrato', associationKey: 'contrato', getterName: 'contrato'}
],
proxy: {
type: "rest",
url: "/chamados"
}
});
Ext.define('Atlas.model.Contrato', {
extend: "Ext.data.Model",
fields: [
'id',
'cliente_id',
{ name: "cliente", mapping: 'cliente.nome', persist: false}
],
belongsTo: [
{model: 'Atlas.model.Cliente', associationKey: 'cliente', getterName: 'cliente'}
],
proxy: {
type: "rest",
url: "/contratos"
}
});
var chamado = Ext.create("Atlas.model.Chamado", {
titulo: "Atendimento por Telefone",
status: {
id: 1,
nome: "Pendente"
}
contrato: {
id: 5609,
cliente: {
id: 1034,
nome: "Grupo Fortes"
}
}
});
chamado.contrato(); //is Null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment