1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    103
    Vote Rating
    0
    muncher is on a distinguished road

      0  

    Default Nested XML mapping - how to ?

    Nested XML mapping - how to ?


    Below is the brief snippet of my xml. It is going to have such multiple <desktop> records -
    Code:
    <desktop>
    <id>1</id>
    <vendor>
                 <name>dell</name>
                 <url>vendor-url</url>
    </vendor>
    <chipset>
                  <id>34</id>
                  <name>intel</name>
    </chipset>
    </desktop>


    my ext-js data store looks something like this -

    Code:
     var store = new Ext.data.Store({
            // destroy the store if the grid is destroyed
            autoDestroy: true,
            
            // load remote data using HTTP
            url: 'plants.xml',
    
            // specify a XmlReader (coincides with the XML format of the returned data)
            reader: new Ext.data.XmlReader({
                // records will have a 'plant' tag
                record: 'desktop',
                // use an Array of field definition objects to implicitly create a Record constructor
                fields: [
                    // the 'name' below matches the tag name to read, except 'availDate'
                    // which is mapped to the tag 'availability'
                    {name: 'id', type: 'string'},
                      .......
                      .......
                    {name: 'description'},
                   
                ]
            }),
    
            sortInfo: {field:'id', direction:'ASC'}
        });
    How do I map those nested fields for example vendor name?

  2. #2
    Sencha User
    Join Date
    Jun 2010
    Posts
    103
    Vote Rating
    0
    muncher is on a distinguished road

      0  

    Default


    ok figured it out.
    basically the mapping field is something like ext.domquery path.
    so in the above case something like
    Code:
    {name: 'vendor-name',mapping:'vendor>name', type: 'string'},
    works

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    The mapping IS a Ext.DomQuery path.

  4. #4
    Sencha User
    Join Date
    Jun 2010
    Posts
    103
    Vote Rating
    0
    muncher is on a distinguished road

      0  

    Default


    Here is the problem that I am looking at -
    Code:
    <a>
      <bs>
         <b></b>
         <b></b>
         <b></b>
      </bs>
      <x></x>
      <y></y>
    </a>
    Above is the xml I am reading. so my xmlreader looks like -
    Code:
     reader: new Ext.data.XmlReader({
        	            // records will have a 'plant' tag
        	            // use an Array of field definition objects to implicitly create a Record constructor
                        record: 'a',
        	            fields: [
        	                {name: 'x', type: 'string'},
        	                {name: 'y', type: 'string'},
        	                {name: 'bs'}
        	               ]
        	        })
    What I am wanting is something like a.bs.b[0] should get me the first b. Does it created nested records ?

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    83
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Someone else asked the same question today. Here is the answer.

Similar Threads

  1. Nested JSON Array Notation Mapping
    By Chrissu in forum Ext 2.x: Help & Discussion
    Replies: 12
    Last Post: 13 Aug 2008, 9:12 AM
  2. Mapping nested json to dynamicColumnModel
    By niks86 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 12 Mar 2008, 10:16 PM
  3. Mapping nested json to dynamicColumnModel
    By niks86 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 9 Mar 2008, 6:23 AM

Thread Participants: 1