1. #1
    Sencha User
    Join Date
    Jun 2012
    Location
    Pune
    Posts
    5
    Vote Rating
    0
    rocknrahul is on a distinguished road

      0  

    Default Unanswered: Display nested list from nested xml with different tags

    Unanswered: Display nested list from nested xml with different tags


    Hello,

    Here is my xml format:

    Code:
    <countries> 
        <country name="countryname1" id="0">
    		<state name="statename1" cid="0" sid="0">
    		.
    		.//some data
    		.
    		</state>
    		<state name="statename2" cid="0" sid="0">
    		.
    		.//some data
    		.
    		</state>
    		<state name="statename3" cid="0" sid="0">
    		.
    		.//some data
    		.
    		</state>
        <country name="countryname2" id="0">
    		<state name="statename1" cid="0" sid="0">
    		.
    		.
    		.
    </countries>
    Now I have to show a list containing countries, and on selecting a country another list should open showing the states of the country.

    Till now i am able to show the county list. But i do not know how should i deal with the nested data.
    my query is:
    1) What model should i use for this xml... should it be nested model ??
    2) If i have to use TreeStore and NestedList, then how shall i do it.. what root should i put in reader in Store as i have to read <country> and then <state>... please help me with some sample code

  2. #2
    Sencha User
    Join Date
    Jun 2012
    Location
    Pune
    Posts
    5
    Vote Rating
    0
    rocknrahul is on a distinguished road

      0  

    Default Well this is what i am trying for now:

    Well this is what i am trying for now:


    I am using a navigation view on which i am displaying countries list. on click of a country i am loading another list, now i know which country i have selected so i am struggling in fetching the states of the selected country, anybody know how to do that ??

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,668
    Answers
    3354
    Vote Rating
    746
    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


    You don't need to use a tree store, in your model do you have a state field that can get the states?
    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.

  4. #4
    Sencha User
    Join Date
    Jun 2012
    Location
    Pune
    Posts
    5
    Vote Rating
    0
    rocknrahul is on a distinguished road

      0  

    Default


    Well I don't know if I am going the right way, but i am trying this:

    Code:
    Ext.define('Sample.model.Countries', {
               extend: 'Ext.data.Model',
               requires: ['Sample.model.Countries'],
               config: {
               fields: [ 
                        { name: 'countryName', mapping: '@country' },
                        { name: 'countryId', mapping: '@id' }
                        ],
               hasMany: {
                        model: 'Mybsm.model.States',
                        associationKey: 'state'
                        }
                    }
               });
    
    
    
    
    Ext.define('Sample.model.States', {
               extend: 'Ext.data.Model',
               config: {
               fields: [ 
                        { name: 'stateName', mapping: '@name' },
                        { name: 'sId', mapping: '@sid' },
                        { name: 'cId', mapping: '@cid' }
                        ],
               belongsTo: 'Sample.model.Countries'
               }
               });
    I am still working on it, is it the right approach?? If it is can you tell me how to fetch state records for a country??

  5. #5
    Sencha User
    Join Date
    Jun 2012
    Location
    Pune
    Posts
    5
    Vote Rating
    0
    rocknrahul is on a distinguished road

      0  

    Default help

    help


    @mitchellsimoens i am still stuck with it. Can you please tell.... how to parse this xml into model and fetch one state item for a country??

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar