Q:

Extjs 4 combo xml store load?

I am using ext-4.2.1, below is the code. It has two problems, (1) buildCategoryStore(), combo can't find the store. (2) the below is the xml data, looks like the store xml reader doesn't work, how to set up the xml root ?
Thanks
Ext.define('App.view.QuestionForm',{
    extend      : 'Ext.form.Panel',
    alias       : 'widget.QuestionForm',
    requires    : [],  

    initComponent   : function(){
        var me = this;

        me.items = me.buildItems();       
        me.callParent();
    },

    buildCategoryStore: function(){
        var CategoryStore = Ext.create('Ext.data.Store', {
            autoLoad: true,
            fields: ['id','name'],
            proxy: {
                type: 'ajax',
                url: 'rs/question/getAllCategories',
                reader: {
                    type:'xml',
                    root: 'CategoryList'
                }
            },
            storeId: 'CategoryStore',
            root: 'CategoryList'
        });
        return CategoryStore;
    },  
    buildItems : function(){
        return [
        {
            xtype: 'combo',
            anchor: '100%',
            fieldLabel  : 'Category',
            store: buildCategoryStore(),
            name: 'category',           
            mode: 'local',
            multiSelect: false
        },

        ];
    },

    }

});

xml data :
<CategoryList>

<Category>
<active>Y</active>
<id>1000</id>
<name>Life</name>
<versionNum>0</versionNum>
</Category>

<Category>
<active>Y</active>
<id>1001</id>
<name>Career</name>
<versionNum>0</versionNum>
</Category>
</CategoryList>

A:

I've fixed up your code. The important parts are you need to call this.foo() and you need to specify the record param for the reader.
Ext.define('App.view.QuestionForm', {
    extend: 'Ext.form.Panel',
    alias: 'widget.QuestionForm',

    requires: [
        'Ext.data.Store'
    ],

    initComponent: function() {
        this.items = this.buildItems();
        this.callParent();
    },

    buildCategoryStore: function() {
        return new Ext.data.Store({
            autoLoad: true,
            fields: ['id', 'name'],
            proxy: {
                type: 'ajax',
                url: 'rs/question/getAllCategories',
                reader: {
                    type: 'xml',
                    record: 'Category'
                }
            }
        });
    },

    buildItems: function() {
        return [{
            xtype: 'combo',
            anchor: '100%',
            fieldLabel: 'Category',
            store: this.buildCategoryStore(),
            name: 'category',
            mode: 'local',
            multiSelect: false,
            valueField: 'id',
            displayField: 'name'
        }];
    }
}); 

