Is there a good was to insert a node after a selected node in a TreePanel ?

  1. #1

    Is there a good was to insert a node after a selected node in a TreePanel ?

    I see the code in the example for inserting a node before the selected node. And that works great. But I'm building a Table of Contents and trying to give the user a way to manage the structure. I know they can insert before and then rearrange (that is working for me), but is there a better way to implement an insertAfter?
  2. #2
    Hello @craigthames!

    Interesting. This method is a "sugar" for inserting nodes on the same level, given the node and TreePanel. But it leaves no way to append a node in the last position of the grid.

    Well, what you can do about that would be something like:

    function insertAfter(node, text) {
      node.parentNode.insertBefore({ text: text || "", loaded: true, leaf: true }, node.nextSibling);
    This should work to append even after the last entry in the tree because according to the documentation on, the node gets appended when the second parameter is null, that would be the case when there's no nextSibling to the passed node.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3



    That was perfect! Thanks so much for your help!

Similar Threads

  1. [CLOSED] how to add a child node to the selected tree node
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 18, 2013, 1:10 AM
  2. Replies: 11
    Last Post: Feb 06, 2013, 5:09 PM
  3. Insert Node to TreePanel eror,why?
    By rainer in forum 1.x Help
    Replies: 4
    Last Post: Mar 31, 2012, 1:12 AM
  4. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  5. Selected Node Id of a TreePanel
    By Z in forum 1.x Help
    Replies: 1
    Last Post: Jul 21, 2010, 8:26 AM

Tags for this Thread

Posting Permissions