View Full Version : [SOLVED]Problem of event for datastore

7 Aug 2009, 2:13 AM
Hello everybody. I'm loading two datastores. One for retrieving info (reportsStore) on reports (sort direction,titles, ids), the other one (store) contains the data of the concerning report. So I would like to set the sort parameters to store. But to do this I first need to retrieve the parameters of reportsStore.

So here's the code:

store.on('load',store.sort(getStoreInfo('orderby', report_id), getStoreInfo('orderdir', report_id)));
function getStoreInfo(param, id)
if(id == -1 && param == 'orderby') return 'id';
if(id == -1 && param == 'orderdir') return 'ASC';

for (var i=0; i<reportsStore.getCount(); i++)
if(reportsStore.getAt(i).get('id') == id){console.log(reportsStore.getAt(i).get(param));
return reportsStore.getAt(i).get(param);}
if(param == 'orderby') return '';
if(param == 'orderdir') return 'ASC';
}The problem is that there is no data yet in reportsStore although it's loaded before store. So... ? Thx

7 Aug 2009, 2:56 AM
You are using the result of the sort() call as the load event handler!


store.on('load', function(){
store.sort(getStoreInfo('orderby', report_id), getStoreInfo('orderdir', report_id));

7 Aug 2009, 3:51 AM
Thank you Condor, I don't sleep enough these times, sorry :))