How to refresh a tree node on context menu click event

Hello Guys,

i want to clear a tree node and reload it again on context menu click .please check this snippet

https://webix.com/snippet/5cf4b651

Tagged:

Comments

  • @webix team any update?

  • edited January 2018

    Hello,
    To delete a node (parent or child) you should use the remove method and specify the id of the required node there:

    tree = webix.ui({ view:"tree",... });
    
    var nodeId = tree.getSelectedId();
    tree.remove(nodeId);
    

    And you can use clearAll and parse to reload it

  • @Nastja thank you for your reply but my requirement is to reload the specific node on context menu click event

  • @qadirkanore can you please clarify, do you intend to reload the branch (child nodes) or just the specific node where the context option is clicked?

  • loadBranch is intended for one-time branch loading, so in order to reload it again, you need to use a custom ajax request
    https://webix.com/snippet/93f8596b

    As for updating one item, if your backend is tuned for returning one record, you can make a custom request and updateItem with the new data:

    webix.ajax().get("/data.php?updateId="+nodeId).then(function(data){
         var update = data.json();
         tree.updateItem(nodeId, update);
    });
    
  • @Listopad i want to reload the child of the node.Thanks a lot for the snippet it helped me to fix my issue

  • Hi,
    How do I refresh a node if I am using the 'url' property to let the Tree component handle Dynamic loading of each child, as per https://docs.webix.com/samples/17_datatree/16_dyn_loading/01_dyn_loading.html
    I have tried using $$("MyTree").Refresh(TreeNode.id) but this does not do anything!
    Thanks
    Antony

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!