PDA

View Full Version : Load data OnDemand ONCE



rockinthesixstring
23 Jun 2011, 9:48 AM
I've got listeners on my controller that load a DataStore when the controller is activated


rpc.controllers.AboutController = new Ext.Panel({
id: 'rpc-controllers-AboutController',
title: 'About',
iconCls: 'info',
layout: 'card',
scroll: 'vertical',
items:[rpc.views.About.index],
dockedItems: [{ xtype: 'toolbar',
title: 'RockPointe Church | Mobile'
}],
listeners: {
activate: function () {
rpc.stores.AboutStore.load();
}
}
});

The problem with this code is that every time you activate the controller, it makes a new request to the store (which is calling an external webservice).

How can I make it so that the store only loads data if it's empty. If it's already got data, it should not "reload"

bharatn
23 Jun 2011, 10:15 AM
look at store.getCount()

rockinthesixstring
23 Jun 2011, 11:26 AM
look at store.getCount()

Nice, that was easy!