Openlayers 如何替换geoext.form.formpanel;
我一直在为这个挠头,我想知道这是否可能。我想用以下方式替换GeoExt.form.FormPanel的协议:Openlayers 如何替换geoext.form.formpanel;,openlayers,javascript,extjs3,Openlayers,Javascript,Extjs3,我一直在为这个挠头,我想知道这是否可能。我想用以下方式替换GeoExt.form.FormPanel的协议: 为了呈现formpanel,我在formpanel外部定义了一个变量“proto”为null(var proto=null) 然后“proto”进入formpanel(协议:proto) 在按钮的处理函数中定义了一个新变量“proto”。我想在formpanel中替换这个新变量 由于extjs、geoext和openlayers都是javascript库,所以我尝试过使用“eval”等方
var proto = null;
var formPanel = new GeoExt.form.FormPanel({
protocol: proto, # <--- replace with [1]
items: [{
xtype: "combo",
id: "idcombo",
etc...
}, {
xtype: "textfield",
id: "idtext",
etc...
}],
button:[{
text: "search",
handler: function() {
formPanel.search();
var combo = Ext.getCmp('idcombo').getValue(); # <--- this works and gets the value chosen in "xtype: combo"
var proto: new OpenLayers.Protocol.HTTP({ # <--- [1] (ie. new variable "proto")
url: "http://www.pub.pub/" + combo + "/somestuff/", # <--- this works
format: etc...
})
}
}]
})
var proto=null;
var formPanel=new GeoExt.form.formPanel({
protocol:proto,#解决方案是只使用“protocol.options.url=newUrl;”而不是protocol.destroy()或protocol.read();完整的解释如下