1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    RenaudM is on a distinguished road

      0  

    Default Unanswered: data association HasMany with no fields

    Unanswered: data association HasMany with no fields


    Hello ,
    i have a XML like this :
    Code:
    <items>
      <item>
    <type>Concert</type>
     <artistes>
      <artiste>Bruce Springsteen</artiste>
      <artiste>Madonna</artiste>
      <artiste>Pink Floyd</artiste>
      </artistes>
    <link>http://wwww.aaaaaaaaa.com</link>
      </item>
    </items>

    but I can't read the "artiste" field with a model without fields :
    PHP Code:
    Ext.define('MyApp.model.artiste', {
        
    extend'Ext.data.Model',
        
    config: {
        }
    }); 
    PHP Code:
    Ext.define('MyApp.model.news', {
        
    extend'Ext.data.Model',
        
    uses: ['MyApp.model.artiste'],
        
    config: {
            
    idProperty'news',
            
    fields: [
                    {
    name'type',type'string'},
                    {
    name'link'}
            ],
            
    hasMany: {
                    
    model'MyApp.model.artiste',
                    
    autoLoadtrue,
                    
    name'artistes'}
            }
    }); 
    and I have this error :
    Code:
    [WARN][Ext.data.Operation#process] Unable to match the record that came back from the server.
    How can I do that ? i tried with a memory proxy but without any success ...

    Will you help me ?

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Toronto, Canada
    Posts
    92
    Answers
    20
    Vote Rating
    12
    iSmartDevice is on a distinguished road

      0  

    Default


    I suppose you will need to add the "associationKey" property in the "hasMany" config.

    http://docs.sencha.com/touch/2-0/#!/...associationKey
    Code:
    hasMany: {
        model: 'MyApp.model.artiste',
        autoLoad: true,
        name: 'artistes', /* This is going to be a store name. ex) record.artistesStore */
        associationKey: 'artistes', /* The name of the property in the data to read the association from */
    }

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    RenaudM is on a distinguished road

      0  

    Default


    Thank you to answer me , but it still no work .

  4. #4
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Why do you have this?

    idProperty: 'news',



    Show us store definitions as well.

  5. #5
    Sencha User
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    RenaudM is on a distinguished road

      0  

    Default


    PHP Code:
    idProperty'news'
    it was a try ... I removed it .

    here my store :
    PHP Code:
    Ext.define('MyApp.store.NewsXmlStore', {
        
    extend'Ext.data.Store',
        
    requires: [
            
    'MyApp.model.news'
        
    ],
        
    config: {
            
    autoLoadtrue,
            
    autoSynctrue,
            
    model'MyApp.model.news',
            
    storeId'NewsXmlStore',
            
    proxy: {
                
    type'ajax',
                
    url'http://www.welovemusic.fr/testflux',
                
    reader: {
                    
    type'xml',
                    
    idProperty'NewsXmlReader',
                    
    rootProperty'items',
                    
    record'item'
                
    }
            }
        }
    }); 

  6. #6
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Don't play with idProperty if you don't really know what it is doing


    reader: {
    type: 'xml',
    idProperty: 'NewsXmlReader',
    rootProperty: 'items',
    record: 'item'
    }





    Why did you set idProperty: 'NewsXmlReader' ?

  7. #7
    Sencha User
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    RenaudM is on a distinguished road

      0  

    Default


    ok , I understood the lesson : i removed all "idProperty" !
    but it still not work

    the full code :

    PHP Code:
    Ext.define('MyApp.store.NewsXmlStore', {
        
    extend'Ext.data.Store',
        
    requires: [
            
    'MyApp.model.news'
        
    ],
        
    config: {
            
    autoLoadtrue,
            
    autoSynctrue,
            
    model'MyApp.model.news',
            
    storeId'NewsXmlStore',
            
    proxy: {
                
    type'ajax',
                
    url'http://www.welovemusic.fr/testflux',
                
    reader: {
                    
    type'xml',
                    
    rootProperty'items'
                   
    record'item'
                
    }
            }
        }
    }); 
    PHP Code:
    Ext.define('MyApp.model.news', {
        
    extend'Ext.data.Model',
        
    uses: [
            
    'MyApp.model.artiste'
        
    ],    config: {
            
    fields: [
                {
                    
    name'type',
                    
    type'string'
                
    },
                
    //here : a lot of fields ...
                 
    {
                    
    name'link'
                
    },
            ],
            
    hasMany: {
                
    associationKey'artistes',
                
    model'MyApp.model.artiste',
                
    autoLoadtrue,
                
    name'artistes'
            
    }
        }
    }); 

    PHP Code:
    Ext.define('MyApp.model.artiste', {
        
    extend'Ext.data.Model',
        
    config: {
         }
    }); 

    and finally :

    PHP Code:
    Ext.define('MyApp.view.MyList', {
        
    extend'Ext.dataview.List',
            
    config: {
                
    store'NewsXmlStore',
                
    itemTpl: [
                            
    '<div>{type}</div>',    // it's ok for that 
                            
    '<br />'
                            
    '<tpl for="artistes">',    // nothing appears ...
                            
    '    <p>{artiste}</p>',
                            
    '</tpl>'
                    
    ]
        }
    }); 

  8. #8
    Sencha User bluehipy's Avatar
    Join Date
    Mar 2010
    Location
    Romania
    Posts
    606
    Answers
    66
    Vote Rating
    26
    bluehipy will become famous soon enough bluehipy will become famous soon enough

      0  

    Default


    Try to read here about models and association:

    http://www.sencha.com/forum/showthread.php?220417-Using-Model-associations-with-two-proxied-Stores




    Y
    our association is not fully defined. Artistes record is artiste but there is no mention of that in your models

  9. #9
    Sencha User
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    RenaudM is on a distinguished road

      0  

    Default


    thank you for the advice and the link : the example is a little bit complex for me , but I'm trying to figure how to apply it on my problem .

Thread Participants: 2

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