How to approach creation of checkable tree, populated asynchronously with data and selection setting. I've tried following example from sencha site: http://examples.sencha.com/gxt/4.0.2...lace:asynctree
but it does not show how to load, keep and update "SelectionModel".
Currently I'm loading my data and selection setting via ChildTreeStoreBinding:
Code:
proxy = new RpcProxyOnFailur<CategoryDTO, List<CategoryDTO>>() {
@Override
public void loadOnFailur(final CategoryDTO loadConfig, final AsyncCallbackOnFailureAware<List<CategoryDTO>> callback) {
CategoryTreeWidget.this.presenter.fetchChildren(loadConfig, callback);
}
};
loader = new TreeLoader<CategoryDTO>(proxy) {
@Override
public boolean hasChildren(final CategoryDTO parent) {
return !parent.isLeaf();
}
};
ChildTreeStoreBinding<CategoryDTO> storeBinding = new ChildTreeStoreBinding<CategoryDTO>(store) {
@Override
public void onLoad(final LoadEvent<CategoryDTO, List<CategoryDTO>> event) {
super.onLoad(event);
for (CategoryDTO category : event.getLoadResult()) {
if (categorySelected.contains(category)) {
tree.setChecked(category, CheckState.CHECKED);
} else {
for (CategoryDTO categoryS : categorySelected) {
if (categoryS.getPathToCategory().startsWith(category.getPathToCategory())) {
tree.setChecked(category, CheckState.PARTIAL);
}
}
}
}
}
};
loader.addLoadHandler(storeBinding);
tree.setLoader(loader);
This solution initialy loads selection setting properly but later on while manipulating tree's selection it does not behave in a proper way because tree is not aware of all node's selection settings - it sees only one, loaded level.
Main question is: how to manage tree's selection model [which nodes are checked, uncheked and partially checked]?
I thought of using TreeSelectionModel class but it does not seem intuitive and actually
I dont know whether it will meet my needs.
Any help or examples will be appreciated.