如何从组合 select listener- extjs 3.4 访问 class 变量

how to access class variables from combo select listener- extjs 3.4

我正在为国家、城市和州创建依赖组合。我在国家/地区组合中有一个 select 侦听器,我在其中调用 loadCityCombo 方法。但是,我无法从 loadCityCombo 访问 cityStore。

我应该做哪些更改才能使依赖组合起作用?

this.country = {
            store : this.countryStore,
            xtype: 'combo',
            fieldLabel : 'Country',
            displayField : 'country',
            valueField : 'country',
            name : 'country',
            typeAhead : true,
            mode : 'local',
            triggerAction : 'all',
            editable : false,
            forceSelection : true,
            allowBlank : false,
            emptyText : 'Select Country',
            listeners : {
                'select' : this.loadCityCombo
            }
        };

this.loadCityCombo = function(country) {
        console.log('load-CityCombo');
        console.log(country);

        var ctyCombo =  (that.mainFormPanel.getComponent('locationDetailsFieldSet')).getComponent('citycombo');
        console.log(ctyCombo);

        var that = this;
        if(country != null){
        var countryName = country.value;
        console.log(this.cityStore);
        console.log(that.cityStore);
        that.cityStore.reload({
            params : {
                country : countryName,start : 1,limit : 1
            }
        });
    }

};

我认为您可能遇到范围问题,请尝试添加

listeners : {
             'select' : this.loadCityCombo,
              scope: this
            }

您应该可以使用 this 关键字而不是您定义的 'that' 变量

编辑 如果没有定义,这通常是指浏览器 window.