1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Chennai, India
    Posts
    71
    Answers
    7
    Vote Rating
    2
    a.premkumar is on a distinguished road

      0  

    Default Unanswered: Associated Model does not generate id automatically

    Unanswered: Associated Model does not generate id automatically


    Hi All,

    I have two models. They are related to each in hasMany-belongsTo manner.

    model ColumnState.js
    Code:
    Ext.define('ExtMVC.model.ColumnState',
    {
        extend:'Ext.data.Model',
        //requires:['ExtMVC.model.PortalState'],
        fields:
        [
            {name:'columnstate_id',type:'int'},
            {name:'columnIndex',type:'int'}
        ],
        
        associations: 
        [
            {
                type: 'hasMany',
                model: 'ExtMVC.model.PortalState',
                associatedName: 'PortalState',
                getterName: 'getPortalState',
                setterName:'setPortalState',
                name: 'portalstate',
                foreignKey: 'portalstate_id',
                instanceName: 'portalstate'
              }
          ],
          
          proxy: 
        {
            type: 'localstorage',
            id  : 'columnstate'
        }
        
    });
    model PortalState.js
    Code:
    Ext.define('ExtMVC.model.PortalState',
    {
        extend:'Ext.data.Model',
        //requires:['ExtMVC.model.ColumnState'],
        fields:
        [
            {name:'portalstate_id',type:'int'},
            {name:'columnstate_id',type:'int'},
            {name:'portalIndex',type:'int'},
            {name:'portalWidth',type:'int'},
            {name:'portalHeight',type:'int'},
            {name:'collapsible',type:'string'}
        ],
        
        associations: 
        [
            {
                type: 'belongsTo',
                model: 'ExtMVC.model.ColumnState',
                associatedName: 'ColumnState',
                getterName: 'getColumnState',
                setterName:'setColumnState',
                name: 'columnstate',
                foreignKey: 'columnstate_id',
                instanceName: 'columnstate'
              }
          ],
          
          proxy: 
        {
            type: 'localstorage',
            id  : 'portalstate'
        }
    });
    I am trying to save data manually first. I am using the following code.

    Code:
    var column1 = Ext.create('ExtMVC.model.ColumnState',{columnstate_id:1,columnIndex:0});
    var column2 = Ext.create('ExtMVC.model.ColumnState',{columnstate_id:2,columnIndex:1});
    var column3 = Ext.create('ExtMVC.model.ColumnState',{columnstate_id:3,columnIndex:2});
    
    
    // Column wolud not generate portalstate() method if I do not instantiate atleast a portalstate model.
    var port1 = Ext.create('ExtMVC.model.PortalState'); //<=============
                   
    var portal1 = column1.portalstate();
    var portal2 = column2.portalstate();
    var portal3 = column3.portalstate();
    
    
    column1.save();
    column2.save();
    column3.save();
                   
    portal1.add([{portalIndex:0,portalWidth:367,portalHeight:300,collapsible:'false'},{portalIndex:1,portalWidth:367,portalHeight:330,collapsible:'false'}]);
    portal1.sync();
    portal2.add([{portalIndex:0,portalWidth:367,portalHeight:150,collapsible:'false'},{portalIndex:1,portalWidth:367,portalHeight:330,collapsible:'false'}])
    portal2.sync();
    portal3.add({portalIndex:0,portalWidth:367,portalHeight:300,collapsible:'false'});
    portal3.sync();
    Please help me. And also in the instantiation issue too.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    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


    I believe this is due to the reader needing to get involved
    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

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi