0

作为 xtype 组合的一部分,我想知道我在简单数据存储中选择的图层(由 表示this.getValue())是否存在于地图图层中。因此,如果发生,A应该发生,B如果没有。问题是该myLayer变量似乎无法识别,即使 Opera Dragonify 根本没有抛出任何错误。错误会在哪里?

listeners: {
  'select': function(combo, record) {
    for(var i = 0; i < mapPanel.map.length; i++) {
      var myLayer = mapPanel.map.layers[i].name;
      if (myLayer == this.getValue()) {
        // do A here...
      } else {
        // do B here...
      }
    }
  }
}

感谢您的任何指点,

4

2 回答 2

1

我认为问题在于您正在使用this.getValue()而不是使用combo.getValue(). 我不知道您的应用程序是如何设置的,但通常最好使用侦听器的第一个参数而不是 keyworkthis以避免范围问题。

希望这可以帮助

于 2014-12-16T00:18:58.537 回答
0

@Guilherme Lopes 谢谢你,但解决方案是:mapPanel.map.layers.length而不是mapPanel.map.length.

于 2014-12-17T08:29:27.167 回答