Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Tree.getOpenList() returns both opened elements and their children

    We've noticed that invoking Tree.getOpenList() we obtain a list containing both the tree elements actually opened/expanded and their children. In fact, invoking Tree.isOpen() on the returned elements we get true only for expanded elements (and not their children).
    The issue can be easily reproduced in the showcase modifying the code snippet as follows:
    Code:
    var grid = isc.TreeGrid.create({
        ID: "employeeTree",
        dataSource: "employees",
        autoFetchData: true,
    
        // customize appearance
        width: 500,
        height: 400,
        nodeIcon:"icons/16/person.png",
        folderIcon:"icons/16/person.png",
        showOpenIcons:false,
        showDropIcons:false,
        closedIconSuffix:""
    });
    
    isc.IButton.create({
        title: 'Count opened elems',
        left: 600, top: 100,
        click: function () {
            var tree = grid.data;
            var openList = tree.getOpenList(tree.root);
            var openCount = 0;
            for (var i =0;i<openList.length;i++) {if (tree.isOpen(openList[i])){openCount++}}
            isc.say ('The number of elements returned by getOpenList is '+openList.length+', but only  '+ openCount+' of them have isOpen=true');
        }
    });
    If you somewhat expand the tree and then press the added button you should see that the number of elements returned by Tree.getOpenList() doesn't match the ones having Tree.isOpen()==true.

    Reproduced using both current showcase (SmartClient Version: 10.0p Built: 2014-09-10) and SmartGWT 4.1p (SmartClient Version: v9.1p_2014-07-20/LGPL Development Only (built 2014-07-20))

    UPDATE: I've noticed that sometimes in the documentation the Tree.getOpenList() is actually considered as a way to obtain the list of visible nodes, so the key matter here is that its name easily generates misunderstandings.
    Last edited by d.cavestro; 8 Oct 2014, 04:18.

    #2
    This is what getOpenList() is documented to do.

    If you found somewhere in the documentation that seems to say getOpenList() has some other behavior, let us know specifically where that is.

    Comment


      #3
      Simply put, the concept of open node is not unequivocally defined by the docs, because:
      • Tree.isOpen() tells us whether a particular node is open or closed...
      • Tree.getOpenList() provides a flattened list of nodes that are open under some parent, including the parent itself...
      • Tree.showRoot docs mention Tree.getOpenList() as the API view components typically use to get the list of visible nodes...

      A developer simply reading Tree.getOpenList() documentation has no way to understand that - in that particular case - the concept of open means that the node is visible. So she could expect that when a node is returned by Tree.getOpenList() this fact implies Tree.isOpen() returns true for that node (as it should be considered open), but that's not always true because the node could simply be a child of an open (not closed) parent.
      It could be considered a nuance, but it took me quite a while to understand the real semantics of Tree.getOpenList().

      Originally posted by Isomorphic View Post
      This is what getOpenList() is documented to do.

      If you found somewhere in the documentation that seems to say getOpenList() has some other behavior, let us know specifically where that is.
      Last edited by d.cavestro; 9 Oct 2014, 05:36.

      Comment


        #4
        Hmm, this confusion has never come up before, but we'll make a slight tweak in the wording regardless just in case.

        Comment

        Working...
        X