REQUIRED INFORMATION


Ext version tested:
  • Ext 4.1 GA


Browser versions tested against:
  • IE9
  • FF11

Description:
  • When I save a model with a hasmany property, the model is updated on the server correctly. But when the model is interpreted by the EXTJS the child relations are not updated correctly.

    After some debugging, I found that the Ext.data.Operation method uses the commitRecords method to copy the server record to the client record.
    The server record is OK, but the client record doesn´t have its child’s updated after the copyFrom method.


Steps to reproduce the problem:
  • Run test case


The result that was expected:
  • Orginal and Copy is equal


The result that occurs instead:
  • Original and Copy is different


Test Case:

Code:
    <!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="http://dbs-gmf-service/extjs/ext-4.1/resources/css/ext-all-gray.css" />
</head>
<body>
</body>
<script type="text/javascript" src="http://dbs-gmf-service/extjs/ext-4.1/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.onReady(function(){

Ext.define('GMF.model.DTODeTelefone', {
    extend: 'Ext.data.Model'
    ,fields: [
        { name: 'Id'}
        ,{ name: 'Telefone'} 
    ]
 ,proxy: {
    type: 'rest',
    url: '/Apresentacao/Telefone'
    , api: {
        read: '/Apresentacao/Telefone/',
        create: '/Apresentacao/Telefone/Novo',
        update: '/Apresentacao/Telefone/Editar',
        destroy: '/Apresentacao/Telefone/Excluir'
    }
    , actionMethods: {
        create: 'POST',
        read: 'GET',
        update: 'POST',
        destroy: 'POST'
    }
    , reader: { root: 'Entidade' }
    }
        ,idProperty : 'Id'
});

Ext.define('GMF.model.DTODePessoaTelefone', {
    extend: 'Ext.data.Model'
    ,fields: [
        { name: 'ID'}
        ,{ name: 'Nome'}
        ,{ name: 'NomeDaMae'}
        ,{ name: 'CPF'} 
    ]
 ,proxy: {
    type: 'rest',
    url: '/Apresentacao/PessoaTelefone'
    , api: {
        read: '/Apresentacao/PessoaTelefone/',
        update: '/Apresentacao/PessoaTelefone/Editar'
    }
    , actionMethods: {
        create: 'POST',
        read: 'GET',
        update: 'POST',
        destroy: 'POST'
    }
    , reader: { root: 'Entidade' }
    }
    , hasMany: [
        { model: 'GMF.model.DTODeTelefone', name: 'Telefones' }
    ]
    , idProperty: 'ID'
});

var pessoaTelefone = Ext.create('GMF.model.DTODePessoaTelefone');
var telefone = Ext.create('GMF.model.DTODeTelefone');
pessoaTelefone.Telefones().add(telefone);

var pessoaTelefoneCopy = Ext.create('GMF.model.DTODePessoaTelefone');
pessoaTelefoneCopy.copyFrom(pessoaTelefone);

document.body.innerHTML = 'Copy: ' + pessoaTelefoneCopy.Telefones().count();
document.body.innerHTML += '<br/>';
document.body.innerHTML +='Original: ' + pessoaTelefone.Telefones().count();

});
</script>


HELPFUL INFORMATION


Debugging already done:
  • commitResults in Ext.data.Operation


Operating System:
  • Win7