1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Vote Rating
    0
    Answers
    4
    izak18 is on a distinguished road

      0  

    Default Unanswered: Store HasMany doesn't sync

    Unanswered: Store HasMany doesn't sync


    Hi, i have a problem saving data in a model type HasMany, this is my code:

    Model:

    Code:
    Ext.regModel('pedidoModel',{    idProperty: 'id',
        fields: [
            {name: 'id', type: 'int'},
            {name: 'ClaseDocumento', type: 'string'},
            {name: 'Referencia', type: 'string'},
            {name: 'CodigoCliente', type: 'string'}
        ],
        associations: [
            {type: 'hasMany', model: 'interlocutoresModel', name: 'interlocutores'}
        ],
        
        proxy:
        {
            type: 'localstorage',
            id: 'pedidoStore'
        }
    });
    
    
    Ext.regModel ('interlocutoresModel', {
        fields: [
            {name: 'pedidoModel_id', type: 'int'},
            {name: 'Funcion', type: 'string' },
            {name: 'Codigo', type: 'string'}
        ],
        
        associations: [
            {type: 'belongsTo', model: 'pedidoModel'}
        ],
     
        proxy: {
            type: 'localstorage',
            id: 'interlocutores'
        }    
    });
    Code:

    Code:
    var currentDoc = interlocutoresView.store.last();
    
    var interStore = currentDoc.interlocutores();
    
    var Funcion = panel1.getValues().Funcion;
    
    var Codigo = panel1.getValues().Codigo;
    
    var inter1 = Ext.ModelMgr.create(
        {'Funcion':Funcion,'Codigo':Codigo},
        'interlocutoresModel'
    );
    
    panel1.load(inter1);
    var currentInter = panel1.getRecord();
    
    interStore.add(currentInter);
    interStore.sync();
    console.log(interStore.data.items);
    I can get the item saved like I see in the console, but when I refresh the page, the data is gone.
    What I can do? Is anything wrong in my code?

    Thanks in advance.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Do you see the sync request fire off in the network tab?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread