Open schitupolu opened 10 years ago
Just to add more about the fiddle.. i created an object in the ELSE block of $watch.. to keep it simple..
Just add selected:"selected" to the node that you want to pre select.
Adding
selected:"selected"
works to pre-select a node. However, when clicking on a different node, both nodes will be selected.
I've added the following in the link
function of the angular.treeview.js
to have the root node selected by default:
//check tree id, tree model
if( treeId && treeModel ) {
// existing code
//new code: if we have a root node, select it by default
if(scope[treeModel][0]) {
scope[treeId].selectNodeLabel(scope[treeModel][0]);
}
I've finally succeeded in doing this while avoiding that unwanted dual selection. There's actually no need to modify the directive.
I'm using this treeview directive wrapped in another directive that adds action buttons to the right of this one.
selected:"selected"
.findSelectedNode
function that finds the first node with a non-undefined 'selected' property.$scope.treeId.currentNode
(the exact same property that would be referenced in the $scope.$watch
mentioned in the Readme) before the watch is installed. (Redefining the node in a variable and assigning it to currentNode
does not work, probably because of a reference problem.)That's all it takes. I still believe that the developer should have dealt with this use case in the Readme.
Cheers!
Hi,
I would like to highlight a selected a node.
Though i am able to select it, but i am not able to highlight the selected node.
Below is the link for the fiddle. http://jsfiddle.net/btrz76s2/
Can someone please provide inputs on how to highlight a node?
Thanks