【问题标题】:how to replace protocol in geoext.form.formpanel‏‏如何替换 geoext.form.formpanel 中的协议
【发布时间】:2013-01-15 10:40:01
【问题描述】:

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

  1. 为了呈现表单面板,我在表单面板之外将变量“proto”定义为 null (var proto = null)。
  2. 然后“proto”进入表单面板(协议:proto)。
  3. 在按钮的处理函数中定义了一个新变量“proto”。我想在表单面板中替换这个新变量。

由于 extjs、geoext、openlayers 是 javascript 库,我尝试了诸如“eval”之类的方法来使处理程序中的变量“proto”在表单面板中可访问,但到目前为止还没有运气。这是一个简化的示例来说明这一点:

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...
            })
        }
    }]
})

我怎么能这样做?感谢您的支持,在此先感谢您。

最好的问候,

格瑞

【问题讨论】:

    标签: openlayers javascript extjs3


    【解决方案1】:

    解决方案是只使用“protocol.options.url = newUrl;”而不是 protocol.destroy();或者protocol.read();,完整的解释是here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-15
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 2020-04-26
      • 1970-01-01
      相关资源
      最近更新 更多