Open srikanthrapolu opened 10 years ago
I've also been trying to figure this out. I've got code that adds data to the tree object but I lose my node highlighting when when I re-draw. I'd like to re-highlight a node after this but I can't find the node. I thought something like $scope.tree.currentNode.selected = 'selected'; might work but no luck.
Try to remove highligh from previous node first (set currentNode to undefined), then assign new node to currentNode and set is and selected. That works for me fine.
We have to pass the particular node information in to selectednode function. It will work. Make sure all values should match with tree view node.
$scope.tree02.selectNodeIcon($scope.ResultFindElement, 1);
selectNodeIcon is the functionality we have to mention it on initialization.
$scope.ResultFindElement is tree view node what we have to select.
data-ng-click="' + treeId + '.selectNodeIcon(node)
@RamaduraiJayaraman : there is no selectNodeIcon
function. And no "selectednode function".
$scope.treeviewId.selectNode(targetNodeObj);
done! see the template in the directive of source code
Hi all, I struck at one point in angular.treeview. I'm trying to show a folder opened dynamically after an update happened in database. Please help me, how to do this.
This is my directive
`appMod.directive("treeModel", function($compile) {
return {
restrict: "A",
link: function(a, f, b, scope) {
var d = b.treeModel,
g = b.nodeLabel || "label",
c = b.nodeChildren || "children",
h = '
h = h+'<i class="fa fa-folder collapsed dynamDatai treeSpn" data-ng-class="node.selected" data-ng-show="node.' + c + '.length && !node.collapsed" data-ng-click="selectNodeLabel(node, $event);selectNodeHead(node, $event)" id="{{node._id}}"></i>';
h = h+'<i class="fa fa-folder-open expanded dynamDataiexpanded treeSpn" data-ng-class="node.selected" data-ng-show="node.' + c + '.length && node.collapsed" data-ng-click="selectNodeLabel(node, $event);selectNodeHead(node, $event)" id="{{node._id}}"></i>';
h = h+'<i class="fa fa-folder collapsed dynamDatai treeSpn" data-ng-class="node.selected" data-ng-hide="node.' + c + '.length" data-ng-click="selectNodeLabel(node, $event);selectNodeHead(node, $event);" id="{{node._id}}"></i>';
//h = h+'<span data-ng-class="node.selected" data-ng-click="selectNodeLabel(node, $event)">{{node.' + g + '}} <span ng-if="node.count > 0">({{node.count}})</span></span>';
h = h+'<span data-ng-class="node.selected" data-ng-click="selectNodeLabel(node, $event);selectNodeHead(node, $event);" class="treeSpn">{{node.' + g + '}} <span ng-if="node.count > 0">({{node.count}})</span></span>';
h = h+'<div data-ng-show="node.collapsed" data-tree-model="node.' + c + '" data-node-id=' + (b.nodeId || "id") + " data-node-label=" + g + " data-node-children=" + c + "></div></li></ul>";
d && d.length && (b.angularTreeview ? (a.$watch(d, function(l, b) {
f.html($compile(h)(a))
}, !1), a.selectNodeHead = a.selectNodeHead || function(a, b) {
a.collapsed = !a.collapsed;
//console.log(a);
}, a.selectNodeLabel = a.selectNodeLabel || function(b, c) {
a.currentNode && a.currentNode.selected && (a.currentNode.selected = void 0);
b.selected = "selected";
a.currentNode = b;
//console.log(b);
}) : f.html($compile(h)(a)))
}
}
})`
This is my html
<div data-angular-treeview="true" data-tree-id="categoryTree" data-tree-model="docCategories" data-node-id="_id" data-node-label="category" data-node-children="subcategories" ng-click="printParent($event);"> </div>
I'm trying to do by the following way, if there is any update in docCategories
$scope.$watch('docCategories', function(){ if($scope.selectedTreeNode){ $scope.selectedTreeNode; setTimeout(function(){ $scope.selectedTreeNode.node.selected = "selected"; $scope.selectedTreeNode.node.collapsed = true; }, 1000); } });
can we select any partcular node by programmatically and open the tree upto selected node