Results 1 to 4 of 4

Thread: parsing problem in xml Cannot call method 'on' of undefined

  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    93
    Vote Rating
    0
      0  

    Default parsing problem in xml Cannot call method 'on' of undefined

    Hi ,
    I am trying to parse XML file in extjs4.1 .I am getting error Cannot call method 'on' of undefined.can anybody tell what is problem .How to fix it?

    This is my xml file
    Code:
    <?xml version="1.0" encoding="windows-1250"?>
    <users>
        <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>
    </users>
    This is my store

    Code:
    Ext.define('TestXml.store.Test', {
        extend : 'Ext.data.Store',
        storeId : 'testStore',
        model : 'TestXml.model.Test',
        autoLoad : 'true',
        proxy : {
            type : 'ajax',
            url : 'test.xml',
            reader : {
                type : 'xml',
                record: 'user',
                rootProperty :'users'
            }
        }
    
    
    });
    This is the model
    Code:
    Ext.define('TestXml.model.Test', {
        extend : 'Ext.data.Model',
        fields : [{
            name : 'id',
            type : 'string'
        }, {
            name : 'name',
            type : 'string'
        }
             
        ]
    });
    This is my app.js
    Code:
     items: [{
              
             xtype : 'combo',
              store : 'testStore', //loading the store
               minWidth : 50,
                minHeight :30,
                displayField :'id',
                 valueField :'name'
              
              }]
    Thanks

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Vote Rating
    247
      0  

    Default

    I tried the following code and your XML (from your examples) and the combobox / store worked as expected in 4.1.1, 4.1.3, and 4.2.

    Code:
    Ext.define('TestXml.model.Test', {
        extend : 'Ext.data.Model',
        fields : [{
            name : 'id',
            type : 'string'
        }, {
            name : 'name',
            type : 'string'
        }
             
        ]
    });
    
    
    Ext.define('TestXml.store.Test', {
        extend : 'Ext.data.Store',
        storeId : 'testStore',
        model : 'TestXml.model.Test',
        autoLoad : 'true',
        proxy : {
            type : 'ajax',
            url : 'data/xml.xml',
            reader : {
                type : 'xml',
                record: 'user',
                rootProperty :'users'
            }
        }
        , listeners: {
            load: function (store) {
                console.log(store.getProxy().getReader().rawData);
                console.log(store.getCount())
            }
        }
    
    
    });
    
    
    Ext.widget('combobox', {
        renderTo: Ext.getBody()
        , displayField: 'id'
        , valueField: 'name'
        , store: Ext.create('TestXml.store.Test')
    });

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    93
    Vote Rating
    0
      0  

    Default

    Thanks slemmon when i used storedId in combo am getting the error cannot call on method undefined

  4. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Vote Rating
    247
      0  

    Default

    In my example the store is defined with a storeId, but until an instance of the store is created you won't be able to use the storeId directly. Using the storeId tells the StoreManager to look up in its managed instances the store with that ID, so it needs to be instantiated first.

    Somewhere between the time the store is defined and when you use it you'd need to do an Ext.create('store.class.name.here'). Then you can use the storeId in your combo's store's store config.

Tags for this Thread

Posting Permissions

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