Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
saifeddineObey opened this issue Aug 10, 2023 · 0 comments
Open

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

saifeddineObey opened this issue Aug 10, 2023 · 0 comments

Comments

@saifeddineObey
Copy link

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);

.... }
}
}
}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant