【发布时间】:2018-07-02 09:59:07
【问题描述】:
我知道有很多关于在另一个函数中调用一个函数的问题,但不幸的是,没有一个对我有用,或者我无法在我的项目中实现!
我有一个Window 类,里面有两个函数。第二个是通过combobox 获取带有 ID 的特定 URL 并返回它。我需要在第一个function 中使用这个生成的URL;
getSelectCountry: function(){
var countryRecord = Ext.ComponentQuery.query('[name=country]')[0].getSelectedRecord();
var countryId = countryRecord.get('id');
var urlWithId = MyApp.Globals.getUrl() + '/city/view/list/?countryid='+ countryId;
// var store = Ext.getStore('cityCombo');
// store.load({
// url : MyApp.Globals.getUrl() + '/city/view/list/?countryid='+ countryId,
// });
return urlWithId;
}
我需要在citycombo 中使用返回的urlWithId,在proxy 的url 内。它将根据以下国家/地区列出城市;
Ext.define('MyApp.view.weather.SettingsWindow', {
...
getSettingsItems: function () {
var me = this;
var settingsItems = [
{
xtype: 'form',
layout: {type: 'vbox', align: 'stretch', pack: 'start'},
reference: 'settingsForm',
items: [
{
xtype: 'citycombo',
itemId: 'cityName',
name: 'city',
afterLabelTextTpl: MyApp.Globals.required,
allowBlank: false,
flex: 1,
store: {
storeId: 'cityCombo',
proxy: {
type: 'ajax',
// I neeed returned URL with ID on here.
url: MyApp.Globals.getUrl() + '/city/view/list/',
reader: {
type: 'json',
rootProperty: 'data'
}
},
pageSize: 0,
sorters: 'description',
autoLoad: true
}
},
我尝试过使用 store.load 或创建一个新变量并调用它,但我无法成功。
我会很高兴有任何想法。
更新
- 请查看屏幕截图:UI 和 code structure
- 我正在尝试获取由
getSelectCountry函数(1) 生成的完整URL,并使用这个新返回的URL (2)citycombo 上的城市查询/strong>。
【问题讨论】:
-
执行 console.log(countryId) 的结果是什么?
-
如果我理解正确的话,你想通过调用getSelectCountry函数来动态确定每个加载操作的URL,对吗?
-
@JorgeMejia 它给了我需要的
integerid;例如 87 并且当控制台urlWithId生成我在 citycombo 上需要的确切 URL 时,例如:URL/city/view/list/?countryid=97 -
@Alexander 我需要从
countrycombo获取此参数,例如?countryid=97,并将其传递到citycombo的url 末尾,例如URL/city/view/list/ ?countryid=97
标签: javascript extjs combobox store getter-setter