我想根據用戶的url更改我的項目視圖中的某個視圖的值。 目前,我有一個商店類,使用loadStore方法動態加載url。Ext JS:將變量分配給商店中的數據
Ext.define('store.app.appStore', {
extend : 'store.Store'
, model : 'model.app.appModel'
, alias : 'widget.app-appstore'
, proxy : {
type : 'rest'
, url : ''
, reader : {
type : 'json'
}
}
, loadStore : function(id) {
this.getProxy().url = app.getApplication().getAppUrl();
console.log(this.getProxy().url);
this.load({});
}
});
並且一個控制器根據id加載url,然後啓動,然後用數據更新我的表單。
Ext.define('controller.app.appController', {
extend : 'Ext.app.Controller',
refs :
{ref : 'appView', selector : 'app-appview'}
],
stores : ['app.appStore'],
init : function() {
this.control({
'app-appview' : {
selectionchange : this.onStartUp
}
});
},
onStartUp : function() {
this.getStore('app.appStore').loadStore();
this.getAppView().updateForm({PARAMETER});
}
不過,我的工作如何分配給我加載數據的變量,所以,在我的updateForm()方法,我將代替{(參數)}與數據有問題。
這個模型看起來是這樣的:
Ext.define('model.app.Summary', {
extend : 'Ext.data.Model',
fields : [
'id', 'name', 'address', 'phone', 'optionOne', 'optionTwo'
],
getId : function() {
return this.get('id');
},
getName : function() {
return this.get('name');
},
getAddress : function() {
return this.get('address');
},
getPhone : function() {
return this.get('phone');
},
getOptionOne : function() {
return this.get('optionOne');
},
getOptionTwo : function() {
return this.get('optionTwo');
},
});
有什麼建議嗎?
你能解釋一下這個'data'事好一些?我不是100%清楚你想傳遞給你的'updateForm()'方法 – benka
,所以我加載了一個有6個字段(基本模型)的對象。我想傳入updateForm的其中一個字段。 – JJI90
你的物體是怎樣的? :) – benka