Sencha touch 自动将selectfield绑定到sencha touch中的存储?

Sencha touch 自动将selectfield绑定到sencha touch中的存储?,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我正在尝试将selectfield绑定到sencha touch中的存储。但是,我得到了以下错误: Uncaught TypeError: Cannot call method 'on' of undefined 该字段看起来是这样的: { xtype: 'selectfield', label: 'Gender', store: 'GenderStore', displayField: 'Ite

我正在尝试将selectfield绑定到sencha touch中的存储。但是,我得到了以下错误:

Uncaught TypeError: Cannot call method 'on' of undefined 
该字段看起来是这样的:

{
            xtype: 'selectfield',
            label: 'Gender',
            store: 'GenderStore',
            displayField: 'ItemName',
            valueField: 'Id'
        },
Ext.define('MobileApp.store.Gender', {
    extend: 'Ext.data.Store',

    requires: [
        'MobileApp.model.Lookup',
        'Ext.data.proxy.Rest'
    ],

    config: {
        autoLoad: true,
        model: 'MobileApp.model.Lookup',
        storeId: 'GenderStore',
        proxy: {
            type: 'rest',            
            url : '/api/lookup/genders',
            reader: {
                type: 'json'
            }
        }
    }    
});
商店看起来是这样的:

{
            xtype: 'selectfield',
            label: 'Gender',
            store: 'GenderStore',
            displayField: 'ItemName',
            valueField: 'Id'
        },
Ext.define('MobileApp.store.Gender', {
    extend: 'Ext.data.Store',

    requires: [
        'MobileApp.model.Lookup',
        'Ext.data.proxy.Rest'
    ],

    config: {
        autoLoad: true,
        model: 'MobileApp.model.Lookup',
        storeId: 'GenderStore',
        proxy: {
            type: 'rest',            
            url : '/api/lookup/genders',
            reader: {
                type: 'json'
            }
        }
    }    
});

你知道为什么这样不行吗?我想指定storeId可能会自动创建与使用xtype类似的存储?该字段是否不会自动绑定到存储,或者是否需要显式创建存储?

确保您的视图需要存储。也许它还不存在(它需要这样才能通过ID找到它):

田野

     {
        xtype: 'selectfield',
        label: 'Gender',
        store: GenderStore,
        displayField: 'ItemName',
        valueField: 'Id'
    },
商店

var GenderStore = Ext.create('Ext.data.Store', {
requires: [
    'MobileApp.model.Lookup',
    'Ext.data.proxy.Rest'
],
autoLoad: true,
model: 'MobileApp.model.Lookup',
proxy: {
    type: 'ajax',            
    url : '/api/lookup/genders',
    reader: {
       type: 'json',
       rootProperty: 'd'
    },
    root: 'd'

}   
});

您好,我已经看到了这一点,但我得到了相同的错误:UncaughtTypeError:无法调用Undefine的“on”方法。我认为令人困惑的是,网络上有一些示例显示了在引号中使用存储id,也有没有引号。此外,是否使用了存储的id以及在存储的别名中指定了什么?真糊涂!。。。您是否在控制器中指定了存储?否则,框架将不知道它是什么。a) 去商店。b) 使用
stores
config在控制器中指定它。c) 在您的视图中使用
storeId
或仅将类名作为字符串指定它。这似乎没有任何区别,下面是我所拥有的内容的粘贴:虽然我看到了这个,但我已经让它工作了。商店现在已在app.js文件中定义,并且似乎正在运行。