1. #1
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Question Variable number of fields inside a model

    Variable number of fields inside a model


    I am working with complex data (in the form of XML) and I have a question.
    How do you work with a variable number of fields inside a model. For instance, below is the data about 2 persons and their cars. But the number of cars is not set/constant. How do you define this in a model, and how do you access the data from the different cars?

    PHP Code:
    <carlist>
    <
    person>
        <
    name>james</name>
        <
    cars>
            <
    car>
                <
    model>Model1</model>
                <
    type>Type1</type>
                <
    licenseplate>AAA-001</licenseplate>
            </
    car>
            <
    car>
                <
    model>Model2</model>
                <
    type>Type2</type>
                <
    licenseplate>BBB-001</licenseplate>
            </
    car>
        </
    cars>
    </
    person>
    <
    person>
        <
    name>Ellen</name>
        <
    cars>
            <
    car>
                <
    model>Model1</model>
                <
    type>Type2</type>
                <
    licenseplate>CCC-001</licenseplate>
            </
    car>
        </
    cars>
    </
    person>
    </
    carlist

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,801
    Vote Rating
    605
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    If you think about it, the cars belong in a separate store. The fields are totally different, so it makes it an 1-N association.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Default


    If you put the cars into a seperate store, how do you read the data? In the example below I get the data from post 1. How do you seperate them into different stores?

    PHP Code:
    carStore = new Ext.data.Store({
                
    model'carlist',
                
    proxy: {
                    
    type:'ajax',
                    
    url'proxytest.php',
                    
    extraParams:{action'askcarlist',
                         
    question'carlist'
                     
    },
                    
    reader: {
                        
    type'xml',
                        
    record'person'
                    
    }
                }


Similar Threads

  1. Replies: 2
    Last Post: 25 Aug 2010, 10:56 PM
  2. Record with variable number of fields?
    By hevole in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 15 Jun 2009, 11:30 AM
  3. help with JsonReader and variable number columns
    By rogerr in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 31 Jan 2008, 7:53 PM

Thread Participants: 1

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