jQuery UI Widgets › Forums › Navigation › Tree › jqxTree AngularJS Directive
Tagged: #angularjsDirective, #jqxtree, #jsonObject, add item, addto, Angular, angular tree, angularjs, data source, id, jquery tree, jqx-settings, jqxtree, json, ng-repeat, parent id, refresh, remove item, removeItem, scope, source, Structure, Tree
This topic contains 19 replies, has 3 voices, and was last updated by Dimitar 8 years, 8 months ago.
-
Author
-
Hi nayanadas,
You can prevent this behaviour with the use of a flag variable, i.e.:
var item8Added = false; $scope.mySettings = { source: $scope.testData, width: '300px', select: function(event) { var item = $scope.tree.getItem(event.args.element); $('#log').text('Selected item: ' + item.label); }, expand: function(event) { if (item8Added === false) { var obj = { id: "8", label: "Item 8" } if ($scope.testData[0].items[0].items) { $scope.testData[0].items[0].items.push(obj); } else { $scope.testData[0].items[0].items = [obj]; } $scope.mySettings.source = $scope.testData; $scope.mySettings.refresh(['source']); item8Added = true; console.log("Changed Json : " + angular.toJson($scope.testData)) } } };
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
I used your method of using flag variable, but it didn’t work. Please check my updated plunker. Still the same issue persist, child nodes are repeating.
Thanking you.
Hi nayanadas,
We tested your Plunker, but no matter how many times a tree item was expanded, “Item 8” was added only once (to “Item 1.1”). It was duplicated only when “Add Node” was clicked, but the flag variable logic is not implemented in $scope.addNode.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
In my plunker, when you expand the first item “Item 1”, the child node is getting added, i.e., “Item 8” is getting added to child node “1.1”. Only in that case, it works. In following cases, it doesn’t work:
1. To expand, when we directly double click on “Item 1.1”, suddenly it will get stuck, then after few seconds, the “item 8” is repeatedly added to “Item 1.1”. And this case, is the actual scenario, what I’m working on. I need to append child nodes on the expanding node.
2. When any other nodes are expanded for example, when I expand “Item 4”, same happens, suddenly it will get stuck, then after few seconds, the “item 8” is repeatedly added to “Item 1.1”.
Thanking you in advance.
Hi nayanadas,
We tested your Plunker (https://plnkr.co/edit/TbgfHxg6RvinWtrc28p6?p=preview) for the reported issue in Chrome, Firefox and Internet Explorer 11, but the erroneous behaviour does not occur. Are you sure you are not referring to a version of your example that has not been shared?
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.