1

在arrayVals中,我有加载时从商店获得的数据,现在我想从菜单项中的arrayVals填充该数据...如果我在加载方法之外调用me.items.push,它可以很好地处理虚拟数据但是当我在加载方法中调用它我收到错误,即 Object [object Object] 没有方法“push”

items = [];
var arrayVals = [];
me.getUserCompanyLogStore().load({
  callback: function (records, operation, success) {
    success: {
      Ext.Array.each(records, function (record, index, array) {
        arrayVals.push(record.get("company"));
      });
      Ext.Array.each(arrayVals, function (record, index, array) {
        console.log(arrayVals)
        me.items.push({ // Object [object Object] has no method 'push'
          xtype: 'main-header-nav-FavoriteItem',
          text: record
        });
      });
    }
  }
});
4

2 回答 2

3

您没有提供完整信息,但这是最可能的情况:

到商店加载时,items不再是一系列配置选项,因为容器已经处理了它们。相反,您需要调用me.add(),因为 items 现在是 MixedCollection 并且配置处理阶段已经过去。

于 2013-09-16T11:00:58.630 回答
0

你可以这样尝试:

var items = [];
var arrayVals = [];
var self = this;
me.getUserCompanyLogStore().load({
  callback: function (records, operation, success) {
    success: {
      Ext.Array.each(records, function (record, index, array) {
        arrayVals.push(record.get("company"));
      });
      Ext.Array.each(arrayVals, function (record, index, array) {
        console.log(arrayVals)
        self.items.push({ // Object [object Object] has no method 'push'
          xtype: 'main-header-nav-FavoriteItem',
          text: record
        });
      });
    }
  }
});
于 2013-09-16T10:16:23.773 回答