Hi, i tried get the selected (checkbox) nodes but unsuccessfully..
utilizing the attribute"activeNodes"
https://github.com/500tech/angular-tree-component/blob/master/lib/defs/api.ts#L458
the return is empty array...
any idea of the problem?
I do not know if it is the best solution, but I used it that way to capture the ids of the selected nodes
Object.keys(tree.treeModel.selectedLeafNodeIds.$mobx.target)
@filipemansano what about when you uncheck some nodes? I came across this same decision trying to get checked leafs but when I uncheck nodes it doesn't refresh selectedLeafNodeIds, just when checking it is being refreshed...
@areisyus I could not find a satisfactory solution, so I created my own tri-state checkbox system
You could use the following to subscribe to state changes.
ngAfterViewInit() {
this.treeComponent.treeModel.subscribeToState((state: any) { // ITreeState does not contain selectedLeafNodeIds
console.log(state);
console.log(this.treeComponent.treeModel.selectedLeafNodeIds);
// drop the unwanted prototypes
const selected = Object.assign({}, this.treeComponent.treeModel.selectedLeafNodeIds);
console.log(selected);
});
}
Closing this issue due to inactivity. Please open a new issue if the problem still exists.
Most helpful comment
You could use the following to subscribe to state changes.