PDA

View Full Version : PagingLoader problem



cutout33
25 Jan 2010, 5:40 AM
Hi All,

Am using paging loader to remotely load a set of data, the problem is some times I need to change the search criteria according to user input so I have drop menu for search options and a sear button, when I click the search button I do the following


Button searchButton = new Button(translations.findUsages(), iconFactory
.search(), new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
type = usagesTypesComboBox.getValue().getValue();
month = monthsComboBox.getValue().getValue().toString();
year = yearsComboBox.getValue().getValue();
if (type.equalsIgnoreCase("data")) {
dataGrid.getStore().getLoader().load();
tabsPanel.setSelection(dataTab);
} else if (type.equalsIgnoreCase("voice")) {
voiceGrid.getStore().getLoader().load();
tabsPanel.setSelection(voiceTab);
} else if (type.equalsIgnoreCase("messages")) {
messagesGrid.getStore().getLoader().load();
tabsPanel.setSelection(messagesTab);
}
type = null;
month = null;
year = null;
}
});

My problem is if the paging result returned by the server contains data the grid hangs on the loading screen and it does not display the new data, but if the result is empty it gives me the empty text of the grid!

here is how a define my grids


RpcProxy<PagingLoadResult<Usage>> proxy = new RpcProxy<PagingLoadResult<Usage>>() {
@Override
public void load(Object loadConfig,
AsyncCallback<PagingLoadResult<Usage>> callback) {
csrService.getUsages((PagingLoadConfig) loadConfig,
accountNumber, month, year, type, callback);

}
};

// loader
final PagingLoader<PagingLoadResult<Usage>> loader = new BasePagingLoader<PagingLoadResult<Usage>>(
proxy);
loader.setRemoteSort(true);

ListStore<Usage> store = new ListStore<Usage>(loader);
final PagingToolBar pagingToolBar = new PagingToolBar(50);
pagingToolBar.bind(loader);

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
createVoiceGridColumns(configs);
ColumnModel cm = new ColumnModel(configs);
messagesGrid = new Grid<Usage>(store, cm);
messagesGrid.setSize(800, 400);
messagesGrid.getView().setEmptyText(translations.noDataAvailable());
messagesGrid.getView().setAutoFill(true);
messagesGrid.getView().setForceFit(true);
messagesGrid.setStateful(true);
messagesGrid.addListener(Events.Attach,
new Listener<GridEvent<Account>>() {
public void handleEvent(GridEvent<Account> be) {
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(50);
Map<String, Object> state = messagesGrid.getState();
if (state.containsKey("offset")) {
int offset = (Integer) state.get("offset");
int limit = (Integer) state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
if (state.containsKey("sortField")) {
config
.setSortField((String) state
.get("sortField"));
config.setSortDir(SortDir.valueOf((String) state
.get("sortDir")));
}
loader.load(config);
}
});
messagesGrid.setLoadMask(true);
messagesGrid.setBorders(true);

this is driving me crazy!!! =P~
can anyone help me please?

cutout33
25 Jan 2010, 6:01 AM
Am really sorry :"> it was a column config issue I was trying to formate a String with time format :P

It is solved now!