Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2515
How to programmatically populate a node with children
posted

I have an igTree configured for LoadOnDemand. I've implemented the nodePopulating event to populate each node with children as I expand the node. Everything works fine.

However, I now find that I need to programmatically populate/expand some of the nodes without requiring a user to click to expand it.

In the igTree rendered event I have something like the following. Unfortunately, since each childNode is not populated, they aren't expanding. There is clearly code somewhere to initiate populating a node since a node gets populated when I click on the  expand indicator. But I can't find anything documented that tells me how I can do it programmatically.

Is there something like $tree.igTree("populate",childNode); available?

var uncheckedNodes = $tree.igTree("uncheckedNodes");
uncheckedNodes.forEach(function (child, i) {
var childNode = child.element;
if (i < 3) {
$tree.igTree("expand",childNode);
}
});
 

Parents
  • 60
    Offline posted

    Hello Ray,

    After having investigated your scenario further, I would like to inform you that you may indeed expand a node programmatically by simply calling the “expand” function of the igTree.

     

    First, you would have to get the node that you would like to expand, this is achieved like so:

    const firstNode = $(“#myTree”).igTree(“nodeByIndex”, 0);

    Please note that there are multiple ways of getting the node that you need, you may find more info here.

    Then expand the node that you just got:

    $(“#myTree”).igTree(“expand”, firstNode);

     

    The “expand” function triggers the population of the node as soon as it is called. Invoking it should allow you to populate nodes programmatically.

     

    Please be sure to contact us again should you require additional assistance.

Reply Children