我正在使用select fiield在我的项目中加载国家/地区。我从数据库加载数据。当我使用autoload时,它非常完美:在我的商店中是true。 但是,当我使用自动加载时,它不会加载:false,并手动加载它。Sebcha Touch选择字段加载问题
附加示例代码,
在此先感谢。
商店
Ext.define("MyProject.store.CountryStore", { extend: 'Ext.data.Store',
storeId: "countryStore",
config: {
model: "MyProject.model.CountryModel",
autoLoad: false, //this is the issue
header: {
"Content-Type": "application/json"
},
proxy: {
type: 'ajax',
url: MyProject.Config.config.webService + 'GetCountries',
//extraParams: {
// sessionId: sessionId
//},
reader: {
type: 'json',
rootProperty: 'd.countries'
},
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
writer: {
encodeRequest: true,
type: 'json'
}
}
}
});
控制器
var CountryStore = Ext.create('MyProject.store.CountryStore', { });
CountryStore.getProxy().setExtraParams({
sessionId: sessionId
});
CountryStore.load({
});
视图
{ xtype: 'selectfield',
name: 'country',
label: 'Country',
store: 'CountryStore',
valueField: 'code',
displayField: 'name',
placeHolder: 'Select your country'
}
模型
Ext.define("MyProject.model.CountryModel", {
extend: 'Ext.data.Model',
config: {
idProperty: 'Id',
fields : [
{ name: 'code'},
{ name: 'name'}
]
}
});
非常感谢您的快速回复。没有其他方法可以做到吗?因为我需要保持我的视图干净(没有任何功能)。无论如何在控制器中都没有吗? – Kasun 2014-09-25 06:30:32
我在控制器中添加业务逻辑 – 2014-09-25 10:54:41
这是正确的。我也打算这样做。非常感谢你。 – Kasun 2014-09-26 19:48:44