Extjs 6组合框「;queryMode:';本地'」;数据不显示

Extjs 6组合框「;queryMode:';本地'」;数据不显示,extjs,extjs6,extjs6-classic,extjs6.5,Extjs,Extjs6,Extjs6 Classic,Extjs6.5,所以我有一个组合框,它是为某个视图动态加载的。 每当我将queryMode设置为remote时,如果单击组合框,它将加载数据,但如果设置为local,它将不会显示任何数据。 我的存储将正确返回请求的数据,只是它不会显示在组合框中 我是不是遗漏了什么? 希望有人能帮助我 这是带有组合框的视图的我的控制器: 我的看法是: 商店: 当您将queryMode设置为local时,这意味着将不会从远程源加载数据,数据应该由例如Ext.data.ArrayStore定义 { xtype: 'combo

所以我有一个组合框,它是为某个视图动态加载的。 每当我将queryMode设置为remote时,如果单击组合框,它将加载数据,但如果设置为local,它将不会显示任何数据。 我的存储将正确返回请求的数据,只是它不会显示在组合框中

我是不是遗漏了什么? 希望有人能帮助我

这是带有组合框的视图的我的控制器:

我的看法是:

商店:


当您将
queryMode
设置为
local
时,这意味着将不会从远程源加载数据,数据应该由例如
Ext.data.ArrayStore定义

{
    xtype: 'combobox'
    queryMode: 'local',    
    valueField: 'id',
    displayField: 'name',
    store: new Ext.data.ArrayStore({
        fields: ['id', 'name'],
        data: [[1, 'item1'], [2, 'item2']] 
    })
}
如果您希望只从远程源加载一次数据,并在本地组合查询数据,则应手动添加存储项

定义您的
组合
如下:

{
    xtype: 'combobox'
    itemId: 'myCombo'
    queryMode: 'local',    
    valueField: 'id',
    displayField: 'name',
    store: new Ext.data.ArrayStore({
        fields: ['id', 'name'],
        data: [] 
    })
}
Ext.Ajax.request({
    url : 'Remote_Source',
    success: function(response, opts) {
         var json = Ext.decode(response.responseText),
             store = me.down("#myCombo").getStore();

         Ext.each(json.items, function(item){
            store.add(item);
         });
     }
});
然后将项目添加到
组合中,如:

{
    xtype: 'combobox'
    itemId: 'myCombo'
    queryMode: 'local',    
    valueField: 'id',
    displayField: 'name',
    store: new Ext.data.ArrayStore({
        fields: ['id', 'name'],
        data: [] 
    })
}
Ext.Ajax.request({
    url : 'Remote_Source',
    success: function(response, opts) {
         var json = Ext.decode(response.responseText),
             store = me.down("#myCombo").getStore();

         Ext.each(json.items, function(item){
            store.add(item);
         });
     }
});
注意:这是您应该添加实现的示例代码

Ext.Ajax.request({
    url : 'Remote_Source',
    success: function(response, opts) {
         var json = Ext.decode(response.responseText),
             store = me.down("#myCombo").getStore();

         Ext.each(json.items, function(item){
            store.add(item);
         });
     }
});