Skip to content

how can I know when the node is fully expanded? #957

@saifeddineObey

Description

@saifeddineObey

Support Requests should not be opened as issues and should be handled in the following ways:

On StackOverflow using the angular-tree-component tag

In our slack support channel at https://angular-tree-component.herokuapp.com/

when i call expandnode method i alwayse receive this error when i try to filter trought the data after the call.
*Here is the code:
expandNode(treeNode: TreeNode, all: boolean = false) { const node = this.tree.treeModel.getNodeById(treeNode.id); if (node != null) { if (all) { this.expandAllNodeLazy(node); } else { node.expand(); } } }
` this.devicetreeService.findNodePath(url).subscribe(
async node => {
this.searchNode = node;
//expand root
var root = this.tree.treeModel.getNodeBy((node) => node.data.entityId == '');
this.collapseNode(root);
this.expandNode(root, false);

    //expand computer
    var pc = root.data.children.filter(pc => pc.name == this.searchNode.computerName)[0];
   this.expandNode(pc, false);
    //expand communicationInterface
    var com = pc.children.filter(com => com.communicationInterfaceDataDTO.interfaceNo == this.searchNode.interfaceNumber)[0];
     this.expandNode(com, false);
    //is TCP/TP or HTTP, serial?
    if (this.searchNode.taId != 0) {
      var ta = com.children.filter(ta => ta.entityId == this.searchNode.taId)[0];
       this.expandNode(ta, false);
    } else {
      var ta = com;
    }
    var device = ta.children.filter(device => device.entityId == sysNr)[0];
    if (this.searchDeviceTyp == 'device') {
      //for auto scroll
      var node = device;
    } else {
      var node = await this.findNodeRecurse(device);
    }
    //select the node
    this.tree.treeModel.getNodeById(node.id).toggleActivated();
    //auto scroll to node
    var labels = document.getElementsByTagName("label");
    for (var i = 0; i < labels.length; i++) {
      if (labels[i].innerHTML == node.name) {
        labels[i].scrollIntoView();
        break;
      }
    }
  }
);`

alwayse after this.expandNode(root, false); I receive this error:
core.js:14597 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'length') TypeError: Cannot read properties of undefined (reading 'length')
and I tried this approach but i didn´t work because when the node take time to expand:
` if (root.data.children && root.data.children.length > 0) {
var pc = root.data.children.filter(pc => pc.name ==
this.searchNode.computerName)[0];

if (pc) {
this.expandNode(pc, false);

if (pc.children && pc.children.length > 0) {
var com = pc.children.filter(com => com.communicationInterfaceDataDTO.interfaceNo == this.searchNode.interfaceNumber)[0];

if (com) {
  this.expandNode(com, false);

.... }
}
}
}
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions