1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    103
    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
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    Answers
    3102
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Do you see the sync request fire off in the network tab?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

Tags for this Thread