Results 1 to 5 of 5

Thread: Create a TreePanel using XmlReader

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    Metz, France
    Posts
    60
    Vote Rating
    2
      0  

    Default Create a TreePanel using XmlReader

    Hello everybody.

    Everything is in the title, I want to create a TreePanel and load data since a xml using a XmlReader.

    Xml is like
    Code:
    <?xml version="1.0" encoding="UTF-8"?><user><id>1</id><name>Ed Spencer</name><email>ed@sencha.com</email></user><user><id>2</id><name>Abe Elias</name><email>abe@sencha.com</email></user>
    
    Can you help me ?

    Thank you,

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997
    Vote Rating
    1524
      0  

    Default

    Try setting the records config to 'user'
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Metz, France
    Posts
    60
    Vote Rating
    2
      0  

    Default

    I have already do that :

    Code:
    Ext.define('User', {
    		extend: 'Ext.data.Model',
    		fields: ['id', 'name', 'email']
    	});
    		
    	var store = new Ext.data.Store({
    		url: 'users.xml',
    		model:'User', 
    		reader: new Ext.data.XmlReader({ 
    			record: 'user'
    		})
    	});
    But I got the error : "me.store.getRootNode is not a function"

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997
    Vote Rating
    1524
      0  

    Default

    Your store isn't setup correctly, it doesn't have a url or reader config, those should be within the proxy config:

    Code:
    new Ext.data.Store({
        model : 'User',
        proxy : {
            type   : 'ajax',
            url    : 'users.xml',
            reader : {
                type   : 'xml',
                record : 'user'
            }
        }
    });
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Location
    Metz, France
    Posts
    60
    Vote Rating
    2
      0  

    Default

    It doesn't work better ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •