YouTip LogoYouTip

Jeasyui Tree Tree3

# jQuery EasyUI Tree Menu - Adding Nodes to the Tree Menu This tutorial shows you how to append nodes to the Tree. We will create a food tree with fruit and vegetable nodes, and then add some other fruits to the existing fruit node. !(#) #### Creating the Food Tree First, we create the food tree, as shown in the following code:
    Note that the Tree component is defined in the
      markup, and the tree node data is loaded from the URL "tree_data.json". #### Getting the Parent Node Then we select the fruit node by clicking on it. We will add some other fruit data. Execute the `getSelected` method to get the selected node: var node = $('#tt').tree('getSelected'); The return value of the `getSelected` method is a javascript object, which has `id`, `text`, and `target` properties. The `target` property is a DOM object referencing the selected node, and its `append` method will be used to append child nodes. #### Appending Nodes var node = $('#tt').tree('getSelected');if (node){var nodes = [{"id":13,"text":"Raspberry"},{"id":14,"text":"Cantaloupe"}];$('#tt').tree('append', {parent:node.target,data:nodes });} After adding some fruits, you will see: !(#) As you can see, using the easyui Tree plugin to append nodes is not that difficult. ## Download jQuery EasyUI Example [jeasyui-tree-tree3.zip](#)
    ← Jeasyui Tree Tree4Jeasyui Tree Tree2 β†’