Ext JS:将 GeoExt 迁移到 v4...“尝试从页面上尚未加载的类进行扩展”

发布于 2024-11-28 19:58:45 字数 2464 浏览 3 评论 0原文

我正在尝试将 Ext 3.3.1 应用程序迁移到 Ext 4(目前带有兼容层)。我在使用 GeoExt 时遇到了一些问题。目前,它在第 99 行中断,显示“尝试从页面上尚未加载的类进行扩展”。 第 99 行是下面的所有代码。

任何有关如何解决此问题的建议或提示将不胜感激。谢谢。

    return selectControl;
},featureSelected:function(evt){
    if(!this._selecting){
        var store=this.grid.store;
        var row=store.findBy(function(record,id){
            return record.data.feature==evt.feature;
        });
        if(row!=-1&&!this.isSelected(row)){
            this._selecting=true;
            this.selectRow(row,!this.singleSelect);
            this._selecting=false;
            this.grid.getView().focusRow(row);
        }
    }
},
featureUnselected:function(evt){
    if(!this._selecting){
        var store=this.grid.store;
        var row=store.findBy(function(record,id){
            return record.data.feature==evt.feature;
        });
        if(row!=-1&&this.isSelected(row)){
            this._selecting=true;
            this.deselectRow(row);
            this._selecting=false;
            this.grid.getView().focusRow(row);
        }
    }
},
rowSelected:function(model,row,record){
    var feature=record.data.feature;
    if(!this._selecting&&feature){
        var layers=this.getLayers();
        for(var i=0,len=layers.length;i<len;i++){
           if(layers[i].selectedFeatures.indexOf(feature)==-1){
               this._selecting=true;
               this.selectControl.select(feature);
               this._selecting=false;
               break;
            }
        }
    }
},
rowDeselected:function(model,row,record){
    var feature=record.data.feature;
    if(!this._selecting&&feature){
        var layers=this.getLayers();
        for(var i=0,len=layers.length;i<len;i++){
            if(layers[i].selectedFeatures.indexOf(feature)!=-1){
                this._selecting=true;
                this.selectControl.unselect(feature);
                this._selecting=false;
                break;
            }
        }
    }
},
getLayers:function(){
    return this.selectControl.layers||[this.selectControl.layer];
}
};
GeoExt.grid.FeatureSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,GeoExt.grid.FeatureSelectionModelMixin);
Ext.namespace("GeoExt","GeoExt.data");
GeoExt.data.LayerReader=function(meta,recordType){
    meta=meta||{};
    if(!(recordType instanceof Function)){
        recordType=GeoExt.data.LayerRecord.create(recordType||meta.fields||{});
    }

I'm trying to migrate an Ext 3.3.1 application to Ext 4 (with the compatabiltiy layer, for now). I've run into some problems with GeoExt. Currently, it's breaking on line 99, saying "Attempting to extend from a class which has not been loaded on the page." Line 99 is all of the code below.

Any sugegstions or hints for how to approach this problem would be greatly appreciated. Thanks.

    return selectControl;
},featureSelected:function(evt){
    if(!this._selecting){
        var store=this.grid.store;
        var row=store.findBy(function(record,id){
            return record.data.feature==evt.feature;
        });
        if(row!=-1&&!this.isSelected(row)){
            this._selecting=true;
            this.selectRow(row,!this.singleSelect);
            this._selecting=false;
            this.grid.getView().focusRow(row);
        }
    }
},
featureUnselected:function(evt){
    if(!this._selecting){
        var store=this.grid.store;
        var row=store.findBy(function(record,id){
            return record.data.feature==evt.feature;
        });
        if(row!=-1&&this.isSelected(row)){
            this._selecting=true;
            this.deselectRow(row);
            this._selecting=false;
            this.grid.getView().focusRow(row);
        }
    }
},
rowSelected:function(model,row,record){
    var feature=record.data.feature;
    if(!this._selecting&&feature){
        var layers=this.getLayers();
        for(var i=0,len=layers.length;i<len;i++){
           if(layers[i].selectedFeatures.indexOf(feature)==-1){
               this._selecting=true;
               this.selectControl.select(feature);
               this._selecting=false;
               break;
            }
        }
    }
},
rowDeselected:function(model,row,record){
    var feature=record.data.feature;
    if(!this._selecting&&feature){
        var layers=this.getLayers();
        for(var i=0,len=layers.length;i<len;i++){
            if(layers[i].selectedFeatures.indexOf(feature)!=-1){
                this._selecting=true;
                this.selectControl.unselect(feature);
                this._selecting=false;
                break;
            }
        }
    }
},
getLayers:function(){
    return this.selectControl.layers||[this.selectControl.layer];
}
};
GeoExt.grid.FeatureSelectionModel=Ext.extend(Ext.grid.RowSelectionModel,GeoExt.grid.FeatureSelectionModelMixin);
Ext.namespace("GeoExt","GeoExt.data");
GeoExt.data.LayerReader=function(meta,recordType){
    meta=meta||{};
    if(!(recordType instanceof Function)){
        recordType=GeoExt.data.LayerRecord.create(recordType||meta.fields||{});
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掀纱窥君容 2024-12-05 19:58:45

我找到了这个。它能解决您的问题吗?

Ext.ux.form.AGrid = Ext.extend(Ext.grid.EditorGridPanel, {
blabla: '测试'
})
尝试使用新的 Ext.define。如果使用动态加载,则需要使用define 和extend: 'someclass'。这样动态加载器将确保首先加载您要扩展的类。

或者,您也可以只使用 ext-all.js 并按照旧的方式进行操作。

http://www.sencha.com/forum/archive/index.php/t-125402.html?s=cdae2bc4c55d9b9436b67d7a799addee

I found this. Does it fix your problem?

Ext.ux.form.AGrid = Ext.extend(Ext.grid.EditorGridPanel, {
blabla: 'test'
})
Try using the new Ext.define. If you are using the dynamic loading, you need to use define with extend: 'someclass'. That way the dynamic loader will make sure to load the class you are extending first.

Alternately you could just use ext-all.js and do it the old way.

http://www.sencha.com/forum/archive/index.php/t-125402.html?s=cdae2bc4c55d9b9436b67d7a799addee

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文