1. #1
    Sencha User
    Join Date
    Feb 2009
    Posts
    6
    Vote Rating
    0
    sdaly is on a distinguished road

      0  

    Default Answered: How to select nested nodes from XML data to display in grid?

    Answered: How to select nested nodes from XML data to display in grid?


    I am trying to select a nested node from xml data to display the node value in a grid. The node I am after is the highestPrice/Price node. I can reference the price node, but that only gives me the first instance. I know that the way HighestPrice/Price is referenced in the model and the grid is not correct. Also, I do not want to change the data structure on the server. Any help with this would be greatly appreciated.

    myPlants.xml:
    HTML Code:
    <catalog>
      <plant>
        <common>Bloodroot</common>
        <botanical>Sanguinaria canadensis</botanical>
        <zone>4</zone>
        <light>Mostly Shady</light>
        <lowestPrice>
            <price>2.44</price>
        </lowestPrice>
        <highestPrice>
            <price>3.44</price>
        </highestPrice>
        <availability>03/15/2006</availability>
        <indoor>true</indoor>
      </plant>
      <plant>
        <common>Columbine</common>
        <botanical>Aquilegia canadensis</botanical>
        <zone>3</zone>
        <light>Mostly Shady</light>
        <lowestPrice>
            <price>9.37</price>
        </lowestPrice>
        <highestPrice>
            <price>10.37</price>
        </highestPrice>
        <availability>03/06/2006</availability>
        <indoor>true</indoor>
      </plant>
    </catalog>
    PlantStore:
    Code:
    Ext.define('PlantStore', {
        extend: 'Ext.data.Store',
        model: 'PlantModel',
        proxy: {
            type: 'ajax',
            url: 'myPlants.xml',
            reader: {
                type: 'xml',
                record: 'plant'
            }
        }
    });
    PlantModel:
    Code:
    Ext.define('PlantModel', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'common', type: 'string'},
            {name: 'botanical', type: 'string'},
            {name: 'light'},
            {name: 'availDate', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
            {name: 'indoor', type: 'bool'},
            {name: 'highestPrice/Price', type: 'float'},   <--  How to do this?
        ]
    });

    PlantGrid:
    Code:
    Ext.define('PlantGrid', {
        extend: 'Ext.grid.Panel',
        alias: 'widget.PlantGrid',
        initComponent: function() {
            Ext.apply(this, {
                store: 'PlantStore',
                columns: [
    {id: 'common',header: 'Common Name',dataIndex: 'common',flex: 1 },
    {header: 'Light',dataIndex: 'light',width: 130,}, {header: 'Highest Price', dataIndex: 'highestPrice/price', width: 130,} <-- How to do this?
    ],
    }); this.callParent(arguments); }, });

  2. Use the mapping config on the field...

    Code:
    mapping : 'highestPrice price'

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,797
    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


    Use the mapping config on the field...

    Code:
    mapping : 'highestPrice price'
    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. #3
    Sencha User
    Join Date
    Feb 2009
    Posts
    6
    Vote Rating
    0
    sdaly is on a distinguished road

      0  

    Default


    I knew there had to be an easy way to do this. Ext and Sencha rock!! Thank you for your help!!

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