I created a sample gxt widget that displays list of record from db.
When I click the refresh button, I would expect the grid data to reload, well it didn't so I thought I could just add an event listener then manually invoke grid.getStore().getLoader().load()
The question is, how do I access the 'Refresh' icon or button on the toolbar so I can attach an event to it.
Please see attached image for the refresh icon I want to handle and snippet below:
private PagingToolBar toolBar;
private NumberFormat currency;
private PagingLoader<PagingLoadResult<ModelData>> loader;
private PagingModelMemoryProxy proxy;
private ListStore<PlayerDTO> store;
proxy = new PagingModelMemoryProxy(null);
loader = new BasePagingLoader<PagingLoadResult<ModelData>>(proxy);
loader.setRemoteSort(true);
store = new ListStore<PlayerDTO>(loader);
toolBar = new PagingToolBar(10);
toolBar.bind(loader);
loader.load(0, 10);
This is how I load the proxy from my rpc callback
final AsyncCallback<List<PlayerDTO>> getPlayersCallback = new
AsyncCallback<List<PlayerDTO>>() {
public void onFailure(Throwable arg0) {
arg0.printStackTrace();
}
public void onSuccess(List<PlayerDTO> arg0) {
proxy.setData(arg0) ;
loader.load(0, 10);
}
};
service.getPlayers(getPlayersCallback);
Thanks for your time,
Babajide Prince.
The refresh button calls loader.load() already, so if one doesn't work, the other won't either. Since you are using a PagingModelMemoryProxy
, I'm guessing you want to do something more than just loader.load(), as loader.load() is just talking to that local data, and not making a round-trip call to the real server. Is that what you mean it to do?
My guess is that you don't actually want to talk to the memory proxy, but to the server in case of refresh, so loader.load() will still give you nothing.
The refresh icon is a protected field in the PagingToolbar
- this means you can subclass the widget and in onRender
or so, add another listener to wire in your specific behavior instead of the loader.load() call that will replace the data in the in-memory proxy you are using.