jQuery UI Widgets Forums Navigation Tree ensureVisible() throws an exception

This topic contains 2 replies, has 2 voices, and was last updated by  Tymek 3 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • Tymek
    Participant

    I use jqWidgets with Angular 6 and when I call function ensureVisible() I get exceotion:
    ERROR TypeError: Cannot read property ‘top’ of undefined
    at init.position (jqxcore.js:14)
    at b.(:4200/anonymous function).ensureVisible (http://localhost:4200/vendor.js:69105:11971)

    This is my code:

    @ViewChild('tree') tree: jqxTreeComponent;
    ...
    
    const item = ...
    if (item !== null) {
       this.tree.expandItem(item);
       this.tree.ensureVisible(item);
       this.tree.selectItem(item);
    }

    Html:

    <jqxTree #tree [width]="'100%'" [height]="'97%'" [source]="treeSource" (onExpand)="onExpand($event)" (onCollapse)="onCollapse($event)"
        (onItemClick)="onItemClick($event)" [allowDrag]="false" [allowDrop]="false" [theme]="theme">
      </jqxTree>

    Expanding and selecting work correctly. How can I solve this problem?


    Martin
    Participant

    Hello Tymek,

    This exception comes from the “item” that you pass to the ensureVisible() function.
    Try passing the HTMLElement of the item you want to ensure visible.
    For example:

    let item = document.getElementById("10");
     this.tree.ensureVisible(item);

    or

    let selectedItem = this.tree.getSelectedItem();
     this.tree.ensureVisible(selectedItem.element);

    It depends on how you get the item.
    If this does not work, please, send a larger example of your code.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

    ensureVisible() throws an exception #100919

    Tymek
    Participant

    Thanks, using “item.element” instead od “item” works.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.