내 프로젝트에서 국가를로드하려면 select fiield를 사용하고 있습니다. 데이터베이스에서 데이터를로드합니다. 내 저장소에서 autoload : true를 사용할 때 완벽하게 작동합니다. 그러나 autoload : false를 사용할 때로드되지 않고 수동으로로드됩니다.Sebcha Touch Select 필드 로딩 문제
샘플 코드가 첨부되어 있습니다.
미리 감사드립니다.
스토어
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
컨트롤러에 비즈니스 로직을 추가하십시오. –
맞습니다. 나는 또한 그렇게 할 것입니다. 고맙습니다. – Kasun