Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers 如何替换geoext.form.formpanel‏‏;_Openlayers_Javascript_Extjs3 - Fatal编程技术网

Openlayers 如何替换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”等方

我一直在为这个挠头,我想知道这是否可能。我想用以下方式替换GeoExt.form.FormPanel的协议:

  • 为了呈现formpanel,我在formpanel外部定义了一个变量“proto”为null(var proto=null)
  • 然后“proto”进入formpanel(协议:proto)
  • 在按钮的处理函数中定义了一个新变量“proto”。我想在formpanel中替换这个新变量
  • 由于extjs、geoext和openlayers都是javascript库,所以我尝试过使用“eval”等方法使处理程序中的变量“proto”可以在formpanel中访问,但到目前为止没有成功。这里是一个简化的示例,说明了这一点:

    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();完整的解释如下