Results 1 to 2 of 2

Thread: Store HasMany doesn't sync

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    104
    Answers
    4
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,421
    Answers
    3901
    Vote Rating
    1271
      0  

    Default

    Do you see the sync request fire off in the network tab?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •