如何覆盖 OpenLayers.Protocol.HTTP 的 url?我试过
searchformPanel.protocol.url
它可以工作(使用console.log检查),但最后会发送原始url(在下面的代码中:url:'/fs/')(见附图)。
这是代码:
var searchformPanel = new GeoExt.form.FormPanel({
border: false,
width: 250,
protocol: new OpenLayers.Protocol.HTTP({
url: '/fs/',
format: new OpenLayers.Format.GeoJSON()
}),
items:[{
xtype: 'combo',
id: 'idcombo',
store: new Ext.data.SimpleStore({
fields:['fsclass','ollayer'],
data:[["Boreholes","Boreholes"],["All_layers","All layers"]]
}),
displayField: 'ollayer',
valueField: 'fsclass',
fieldLabel: 'Layer',
emptyText: 'select a layer',
submitValue: false,
selectOnFocus: true,
mode: 'local',
typeAhead: true,
editable: false,
forceSelection: true,
triggerAction: 'all'
},{
xtype: 'textfield',
id: 'idtextfield',
fieldLabel: 'Find features',
emptyText: 'enter word',
name: 'comments__like',
allowBlank: false
}],
listeners:{
actioncomplete: function(form, action){
searchShowTip(action.response.features);
}
},
buttons:[{
text: 'search',
listeners:{
click: function(){
var comboLayer = Ext.getCmp('idcombo').getRawValue();
var keyword = Ext.getCmp('idtextfield').getRawValue();
var newUrl = '/fs/' + comboLayer + '?format=GeoJSON&comments__ilike=' + keyword + '&queryable=comments';
console.log('1:' + newUrl);
//this gets '/fs/' from the searchformPanel
console.log('2:' + searchformPanel.protocol.url);
searchformPanel.protocol.url = newUrl;
console.log('3:' + searchformPanel.protocol.url);
searchformPanel.search();
}
}
}]
});
非常欢迎对此的任何支持,谢谢!