jQuery UI Widgets Forums Angular Angular update treeitem

This topic contains 8 replies, has 2 voices, and was last updated by  Martin 4 years, 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • Angular update treeitem #100513

    TSKishore
    Participant

    Hello,

    I have a treecomponent with source, the tree has multiple levels. i need to delete and update a particular node.

    i have updated the source but in the ui it does not reflect, so i have used:
    this.mytree.updateItem(node, newnode);
    but this doesnt work for me.

    delete:
    this.mytree.removeitem() worked but source is not getting updated.

    Angular update treeitem #100514

    Martin
    Participant

    Hello TSKishore,

    After you have updated your source, pass it to the tree again, like this:
    this.myTree.source(this.source);,
    this will reflect in the ui.

    Best Regards,
    Martin

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

    Angular update treeitem #100515

    TSKishore
    Participant

    Hello Martin,

    Thanks that worked.

    For Delete : From source i’m not able to delete particular node.

    Angular update treeitem #100527

    Martin
    Participant

    Hello TSKishore,

    You can ‘delete’ a node from your source by passing it an empty object.
    this.source[1] = {};

    When you pass the source to the tree again, the node will be removed from the ui.

    Best Regards,
    Martin

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

    Angular update treeitem #100531

    TSKishore
    Participant

    Hello Martin,

    I’m trying to delete a particular node from multi level tree.

    If i pass empty object, a node labeled “item” is replacing the node which i deleted.

    Angular update treeitem #100539

    Martin
    Participant

    Hello TSKishore,

    Then you can try removing the node from its array in the node using splice.
    Here is a Demo for example.
    Using ‘splice’ will remove the node and re-index the array.
    In the above example this.treeSource[1] = {}; also works, but this would depend on the structure of your data.

    Best Regards,
    Martin

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

    Angular update treeitem #100601

    TSKishore
    Participant

    Hello Martin,

    In Demo, only the first node is deleted. In my scenario I want to delete the child nodes of first node or so on.
    or even node[i].items[i].items[i].

    Regards,
    Kishore

    Angular update treeitem #100602

    TSKishore
    Participant

    Hello Martin,

    Once I use splice on the particular node, I’m not able to add new node to that node.

    Regards,
    Kishore

    Angular update treeitem #100605

    Martin
    Participant

    Hello TSKishore,

    You can use “splice” again to add new node to a particular position in the tree.

    I’ve updated the Demo.
    For this example, I only delete the second child of the first node and insert at the same position. Of course, you can modify this with your own logic.

    Here you can check how “splice” works for inserting items to an array.

    Best Regards,
    Martin

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

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

You must be logged in to reply to this topic.