Closed AmarKoli closed 8 years ago
Hi!
To select a node programmatically the only thing you have to do is include the property "selected = true" in your node model.
To show a list of the node selected you can use the callbacks included when nodes are selected and keep a list in your controller. Keep in mind that if you select a node by yourself (without interact with the tree, you have to control this list manually)
I created a quick example for you here: https://embed.plnkr.co/eGsGnFiA6Pi8qR46ZuPt/
hey, thanks for the help. i am very new to angularjs, so trying vey basic thing. i don't want to store the selected node list in array, just want the node to be selected and along with it, it should trigger its 'selection-changed' event. what i am doing is just this $scope.selectNode = function(){ var node = $scope.menuTree[0]; node.selected = !node.selected; } this does toggle the selection of the 1st node, but does not trigger its 'selection-changed' event. what else i need to do? would be great if you can help me with this. check the example i set here https://plnkr.co/edit/aCMZxJ?p=preview
Since you set the node programmatically, you already know which node you want to handle. On this assumption the control is create.
On the 'selectNode' function you can set the correct value of the 'selectedNode' variable.
If you want to do something more complex you can build a new function which will set this value; and call this function both on the 'selection-changed' event or on the 'selectNode' function.
hi AlexSuleap,
thanks for the help, this is exactly what is required. thanks a ton.
How to programmatically select a node. how to show the 1st node selected, or any other node selected when the tree is loaded. can you help me with this.