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 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,556
    Answers
    3932
    Vote Rating
    1272
      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! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •