Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

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

$
0
0
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.

Viewing all articles
Browse latest Browse all 4756

Trending Articles