jQuery UI Widgets Forums Navigation Tree Angular Tree – Change Childrens

This topic contains 1 reply, has 2 voices, and was last updated by  Martin 6 years ago.

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

  • pantxisto
    Participant

    Hello,

    I´m trying to change childrens of a node with this code below:

    const selectedItem = this.tree.getItem($(‘#’ + id).get(0));
    const newItem = dataAdapter.records;
    const label = selectedItem.label;
    const childrenLevel = selectedItem[‘level’] + 1;
    const allItems = this.tree.getItems();
    // tslint:disable-next-line:max-line-length
    const removingItems = allItems.filter(item => item.parentElement !== undefined && item[‘level’] === childrenLevel && this.tree.getItem(item.parentElement).label === label);

    for (let i = 0; i < removingItems.length; i++) {
    this.tree.removeItem(removingItems[i].element);
    }

    this.tree.addTo(newItem , selectedItem.element);
    this.tree.refresh();

    The problem is that this works really slow. Is there any other solution?

    Thanks


    Martin
    Participant

    Hello pantxisto,

    Yes, this is the correct approach for changing children items.

    Another thing you can do, is just to update the source of the tree.
    Here is an Example.

    Best Regards,
    Martin

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

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

You must be logged in to reply to this topic.