I know this can be a matter of debate (to make sync or async calls) but here is my scenario:
I have a property grid, wich have a custom renderer function and a custom editor which is a combobox
The thing is that by whe the property is created the datastore is still loading and renderer function fails to findRecord because data isn't populated yet
i've tried async: false everywhere in model,proxy,reader with no success
i've found 2 workarounds
1. wait until store.loading==false
2. check if loading and if loading return plain value instead the text of the combo (next click will render ok)
Example code below
Code:
if(!Ext.getStore('optionsStore')){
Ext.create('Ext.data.Store', {
id:'optionsStore',
autoLoad: true,
model: 'Options',
async : false,
proxy: {
type: 'ajax',
async : false,
url: base_url+'dna2/form/get_options', // url that will load data with respect to start and limit params
noCache: false,
reader: {
async:false,
type: 'json',
root: 'rows',
totalProperty: 'totalCount'
}
}
});
}
and the renderer wich throw the error if data isn't loaded yet
Code:
customRenderer=function(){
return value+' :: '+optionsStore.findRecord('idop',value).data.title;
}
and the renderer without error (but doesn't show propper value)
Code:
customRenderer=function(){
if(!optionsStore.loading){
return value+' :: '+optionsStore.findRecord('idop',value).data.title;
} else {
return value;
}
}