jQuery UI Widgets Forums Navigation Tree jqxTree AngularJS Directive

This topic contains 19 replies, has 3 voices, and was last updated by  Dimitar 8 years, 8 months ago.

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
  • jqxTree AngularJS Directive #85337

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    jqxTree AngularJS Directive #85409

    nayanadas
    Participant

    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.

    jqxTree AngularJS Directive #85452

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    jqxTree AngularJS Directive #85486

    nayanadas
    Participant

    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.

    jqxTree AngularJS Directive #85502

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 5 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic.