addNodeReturns: jQuery object

Add node to the tree.

Parameters

NameTypeDescription
data {object} The node data.
parentNode {object} Parent node as jquery object.
position {Number} Position where the new node need to be added.

Examples

Append ToRoot

    
 <button onclick="append()" class="gj-button-md">Append To Root</button>
 <br/>
 <div id="tree" data-source="/Locations/Get"></div>
 <script>
     var tree = $('#tree').tree();
     function append() {
         tree.addNode({ text: 'New Node' });
     }
 </script>

  

Append Parent

    
 <button onclick="append()" class="gj-button-md">Append To Asia</button>
 <br/>
 <div id="tree" data-source="/Locations/Get"></div>
 <script>
     var parent, tree = $('#tree').tree();
     tree.on('dataBound', function () {
         parent = tree.getNodeByText('Asia');
         tree.off('dataBound');
     });
     function append() {
         tree.addNode({ text: 'New Node' }, parent);
     }
 </script>

  

Bootstrap

    
 <button onclick="append()" class="btn btn-default">Append To Asia</button>
 <br/><br/>
 <div id="tree" data-source="/Locations/Get" data-ui-library="bootstrap"></div>
 <script>
     var parent, tree = $('#tree').tree();
     tree.on('dataBound', function () {
         parent = tree.getNodeByText('Asia');
         tree.off('dataBound');
     });
     function append() {
         tree.addNode({ text: 'New Node' }, parent);
     }
 </script>

  

Prepend

    
 <button onclick="append()" class="gj-button-md">Prepend in Asia</button>
 <br/>
 <div id="tree" data-source="/Locations/Get"></div>
 <script>
     var parent, tree = $('#tree').tree();
     tree.on('dataBound', function () {
         parent = tree.getNodeByText('Asia');
         tree.off('dataBound');
     });
     function append() {
         tree.addNode({ text: 'New Node' }, parent, 1);
     }
 </script>

  

Position

    
 <button onclick="append()" class="gj-button-md">Append to Asia as second</button>
 <br/>
 <div id="tree" data-source="/Locations/Get"></div>
 <script>
     var parent, tree = $('#tree').tree();
     tree.on('dataBound', function () {
         parent = tree.getNodeByText('Asia');
         tree.off('dataBound');
     });
     function append() {
         tree.addNode({ text: 'New Node' }, parent, 2);
     }
 </script>