I'm using october's version of GXT, so it's possible that it was addressed somehow.
In case it's not yet fixed please see the testing code below. Make sure that number of rows visible is greater than 8, which is probably cacheSize (=10) * (1 - preloadFactor (=0.2)).
The button flips the flag and reloads the loader. Once you press the button it starts loading rows indefinitely.
Everything's in one file (imports are stripped).
Code:
public class TestComponent extends ContentPanel {
private final class FileListProxy extends
RpcProxy<BasePagingLoadResult<ModelData>> {
@Override
protected void load(Object loadConfig,
final AsyncCallback<BasePagingLoadResult<ModelData>> callback) {
if (_loadAllowed) {
PagingLoadConfig pagingLoadConfig = (PagingLoadConfig) loadConfig;
int offset = pagingLoadConfig.getOffset();
int limit = pagingLoadConfig.getLimit();
ArrayList<ModelData> mds = new ArrayList<ModelData>(offset
+ limit);
for (int i = offset; i < offset + limit; i++) {
BaseModelData md = new BaseModelData();
md.set("name",
"item_" + i + "_" + System.currentTimeMillis());
mds.add(md);
}
BasePagingLoadResult<ModelData> result = new BasePagingLoadResult<ModelData>(
mds, offset, 1000);
callback.onSuccess(result);
} else {
callback.onSuccess(new BasePagingLoadResult<ModelData>(
new ArrayList<ModelData>(0), 0, 0));
}
}
}
private static final class FileListDataReader implements
DataReader<PagingLoadResult<ModelData>> {
@Override
public PagingLoadResult<ModelData> read(Object loadConfig, Object data) {
return (BasePagingLoadResult<ModelData>) data;
}
}
private Grid<ModelData> _fileGrid;
private final FileListProxy _fileListProxy;
private final PagingLoader<PagingLoadResult<ModelData>> _fileListLoader;
private final ListStore<ModelData> _fileListStore;
private boolean _loadAllowed = false;
public TestComponent() {
super(new FillLayout());
_fileListProxy = new FileListProxy();
_fileListLoader = new BasePagingLoader<PagingLoadResult<ModelData>>(
_fileListProxy, new FileListDataReader());
_fileListLoader.setRemoteSort(true);
_fileListLoader.setSortDir(SortDir.DESC);
_fileListLoader.setSortField("name");
_fileListStore = new ListStore<ModelData>(_fileListLoader);
}
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setHeading("Live Grid Test");
List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
ColumnConfig nameColumn = new ColumnConfig("name", "Name", 300);
columns.add(nameColumn);
ColumnModel cm = new ColumnModel(columns);
_fileGrid = new Grid<ModelData>(_fileListStore, cm);
_fileGrid.setLoadMask(true);
LiveGridView liveGridView = new LiveGridView();
liveGridView.setEmptyText("No records found");
liveGridView.setCacheSize(10);
_fileGrid.setView(liveGridView);
add(_fileGrid);
Button loadButton = new Button("Load/Unload",
new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
_loadAllowed = !_loadAllowed;
_fileListLoader.load();
}
});
LiveToolItem pageLabel = new LiveToolItem();
pageLabel.bindGrid(_fileGrid);
ToolBar bottomBar = new ToolBar();
bottomBar.add(loadButton);
bottomBar.add(new FillToolItem());
bottomBar.add(pageLabel);
add(bottomBar);
}
}