Javascript 组合框索引获取[object object],而不是extjs中的数字

Javascript 组合框索引获取[object object],而不是extjs中的数字,javascript,jquery,extjs,Javascript,Jquery,Extjs,我在Ext.TaskManager中运行了和extjs任务,它每5秒重新加载一次我的Ext存储。每次调用任务时,我都会更新保存组合框中当前选定索引(值)的currentIndex变量。我遇到的问题是,在某些情况下,currentIndex不是获取数字,而是获取值[object]。我真的不知道为什么会这样。以下是我的示例代码: // combo store var myStore = Ext.create('Ext.data.Store', { id: store_id, fiel

我在Ext.TaskManager中运行了和extjs任务,它每5秒重新加载一次我的Ext存储。每次调用任务时,我都会更新保存组合框中当前选定索引(值)的currentIndex变量。我遇到的问题是,在某些情况下,currentIndex不是获取数字,而是获取值[object]。我真的不知道为什么会这样。以下是我的示例代码:

// combo store
var myStore = Ext.create('Ext.data.Store', {
    id: store_id,
    fields: ['label', 'value', 'type'],
    autoLoad: true,
    proxy: {
        type: 'ajax',
        url: '/url/to/controller',
        reader: {
            type: 'json',
            root: 'MyModel'
        }
    }
}),

 createWindow = function() {
    var myComboBox = Ext.create('Ext.form.field.ComboBox', {
        flex: 3,
        editable: false,
        value: 'Select option',
        displayField: 'label',
        valueField: 'value',
        store: myStore,
        cls: 'comboCssClass',
        id: ComboBoxId,
        listeners: {
            'select': function(combo, row, index) {
                var rowData = row[0].data;
                currentIndex = this.getValue();
             }
        }
   };

   return newWindow = Ext.create('Ext.widget.window',{
          // window settings
          items:[myComboBox ]
   });
},

reloadStoretask = {
    run: function(){
          myStore.load();

          // here is where in some cases I get [object Object] instead of number 
          // And I think the object is Ext.data.store.ImplicitModel or it was alike. 
          // so currentIndex = [object Object] in some cases
          record = myStore.getAt(currentIndex).data;
    },
    interval: 5000
}

如何修复此问题或我做错了什么?

可能是您加载了两次存储,您使用autoload:true配置了存储,然后调用reloadStoretask函数来重新加载存储。

您在哪里调用myComboBox来运行?很不幸,它是在创建extjs窗口的单独函数中创建的。请参阅更新的代码错误发生时用于填充存储的数据是什么?Auu我想我删除了“MyModel”,即ethere不是MyModel。这可能是问题所在吗?嗯,在你调用combobox的地方仍然没有摆动。。。如果将其包含在items数组中,是否有调用列表中函数的内容?是的,看来我的模型找不到了。