Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] How to add a tree node ? (alphabetical)

Expand Messages
  • Satyam
    The Node has insertAfter and insertBefore: http://developer.yahoo.com/yui/docs/YAHOO.widget.Node.html#method_insertAfter so you can insert the node wherever
    Message 1 of 2 , Jan 11, 2009
    • 0 Attachment
      The Node has insertAfter and insertBefore:

      http://developer.yahoo.com/yui/docs/YAHOO.widget.Node.html#method_insertAfter

      so you can insert the node wherever you want. Each node has a children
      property which is an array of child nodes. You can loop through this
      array to find the position for the new node and then insert it accordingly.

      Satyam


      zedan_gu wrote:
      > I want to add a node to tree view, and I hope the new node is placed
      > on where according to alphabetical order, rather than the end of the
      > tree nodes ( default action). How can I do to achieve my demand? how
      > to rework the YUI core code?
      > for example:
      > tree view A : nodeA, nodeB, nodeD;
      > and i add a node named "nodeC";
      > after default action, the tree now is: nodeA, nodeB, nodeD, nodeC;
      > but i hope it is: nodeA, nodeB, nodeC, nodeD;
      >
      > give me a hand plz.
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - http://www.avg.com
      > Version: 8.0.176 / Virus Database: 270.10.5/1885 - Release Date: 09/01/2009 19:59
      >
      >
    • zedan_gu
      Thanks first, I tried according what you said, but there is other issue. my code: nodeC = new YAHOO.widget.TextNode(data, null, false); //note: parent node set
      Message 2 of 2 , Jan 11, 2009
      • 0 Attachment
        Thanks first,
        I tried according what you said, but there is other issue.
        my code:
        nodeC = new YAHOO.widget.TextNode(data, null, false); //note:
        parent node set to null;
        nodeB.insertAfter(nodeC); // error: TypeError: this.tree is
        undefined /Line 1853 of treeview.js.

        anther code:
        nodeC = new YAHOO.widget.TextNode(data, pNode, false); //note:
        set a parent node
        nodeB.insertAfter(nodeC);
        //result: nodeC' position is correctly, but nodeB is placed to the
        end of pNode.

        What happens?


        --- In ydn-javascript@yahoogroups.com, Satyam <satyam@...> wrote:
        >
        > The Node has insertAfter and insertBefore:
        >
        >
        http://developer.yahoo.com/yui/docs/YAHOO.widget.Node.html#method_insertAfter
        >
        > so you can insert the node wherever you want. Each node has a children
        > property which is an array of child nodes. You can loop through this
        > array to find the position for the new node and then insert it
        accordingly.
        >
        > Satyam
        >
        >
        > zedan_gu wrote:
        > > I want to add a node to tree view, and I hope the new node is placed
        > > on where according to alphabetical order, rather than the end of the
        > > tree nodes ( default action). How can I do to achieve my demand? how
        > > to rework the YUI core code?
        > > for example:
        > > tree view A : nodeA, nodeB, nodeD;
        > > and i add a node named "nodeC";
        > > after default action, the tree now is: nodeA, nodeB, nodeD,
        nodeC;
        > > but i hope it is: nodeA, nodeB, nodeC, nodeD;
        > >
        > > give me a hand plz.
        > >
        > >
        > > ------------------------------------
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        ------------------------------------------------------------------------
        > >
        > >
        > > No virus found in this incoming message.
        > > Checked by AVG - http://www.avg.com
        > > Version: 8.0.176 / Virus Database: 270.10.5/1885 - Release Date:
        09/01/2009 19:59
        > >
        > >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.