你好朋友我正在开发一个GWT应用程序,我正在使用TreeGrid。当我在这个矿类中使用常规网格时:
RpcProxy<ListLoadResult<GwtDatastoreAsset>> proxy = new RpcProxy<ListLoadResult<GwtDatastoreAsset>>() {
@Override
protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtDatastoreAsset>> callback) {
if (selectedDevice != null) {
dataService.findAssets((LoadConfig) loadConfig, currentSession.getSelectedAccount().getId(), selectedDevice, callback);
}
}
};
loader = new BaseListLoader<ListLoadResult<GwtDatastoreAsset>>(proxy);
loader.load();
SwappableListStore<GwtDatastoreAsset> store = new SwappableListStore<GwtDatastoreAsset>(loader);
assetGrid = new Grid<GwtDatastoreAsset>(store, new ColumnModel(configs));
assetGrid.setBorders(false);
assetGrid.setStateful(false);
assetGrid.setLoadMask(true);
assetGrid.setStripeRows(true);
assetGrid.getView().setAutoFill(true);
assetGrid.getView().setEmptyText(MSGS.assetTableEmptyText());
assetGrid.disableTextSelection(false);
在我的刷新方法的这个类中,我只做了assetGrid.getStore()。getLoader()。load(); 就是这样,但是对于TreeGrid,我不能这样做。这是我使用TreeGrid的方法:
AsyncCallback<List<GwtTopic>> topicsCallback = new AsyncCallback<List<GwtTopic>>() {
@Override
public void onSuccess(List<GwtTopic> topics) {
store.add(topics, true);
topicInfoGrid.unmask();
}
@Override
public void onFailure(Throwable t) {
FailureHandler.handle(t);
topicInfoGrid.unmask();
}
};
dataService.findTopicsTree(currentSession.getSelectedAccount().getId(), topicsCallback);
topicInfoGrid = new TreeGrid<GwtTopic>(store, new ColumnModel(configs));
topicInfoGrid.setBorders(false);
topicInfoGrid.setStateful(false);
topicInfoGrid.setLoadMask(true);
topicInfoGrid.mask("Loading");
topicInfoGrid.setStripeRows(true);
topicInfoGrid.getView().setAutoFill(true);
topicInfoGrid.getView().setEmptyText(MSGS.topicInfoGridEmptyText());
topicInfoGrid.disableTextSelection(false);
所以我的问题是如何为TreeGrid制作刷新方法,就像我使用常规网格一样。
答案 0 :(得分:0)
TreeGrids有自己的加载器,称为TreeLoader,而不是使用商店的加载器:https://docs.sencha.com/gxt/3.x/javadoc/com/sencha/gxt/widget/core/client/treegrid/TreeGrid.html#setTreeLoader(com.sencha.gxt.data.shared.loader.TreeLoader)
答案 1 :(得分:0)
尝试在 onSuccess 方法之后添加:
topicInfoGrid.getTreeView().refresh(true);
或者如果刷新不起作用
topicInfoGrid.reconfigure(store, cm, treeColumn);