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

Re: [ydn-javascript] Possibility of Node Sort

Expand Messages
  • Brandon Fosdick
    ... I ve been trying to figure out how to do the same thing. Rearranging the labels doesn t quite work in my case because the nodes have data associated with
    Message 1 of 3 , Jul 1, 2006
    • 0 Attachment
      Nige White wrote:
      > You could just iterate through thr Nodes changing the label text to the
      > correct value to change the appearance to being sorted.
      >
      > It should be possible to write a node sorting method. Just look at
      > treeview.js. Each Node has an array called "children", each of which is
      > a Node.
      >
      > Every child Node has a nextSibling and previousSibling pointer. You can
      > sort that array as you see fit, then make a pass through updating the
      > sibling pointers, call refresh() on the parent Node, and that *should*
      > do it... YMMV!
      >
      > I've done a bit of "Node shuffling" when adding drag and drop to my
      > DDTreeView class, so I think that should work.

      I've been trying to figure out how to do the same thing. Rearranging the labels doesn't quite work in my case because the nodes have data associated with them and some nodes could gain or lose children during the update. Calling refresh() on the node is exactly what I'm trying to avoid because it creates a discontinuity in the UI.

      I think it should be possible to change the sibling pointers on the DOM elements directly, as opposed to just the tree nodes, but I don't know if the browser will automatically rearrange the items when that happens. Anybody know for sure? I haven't tried it yet.
    Your message has been successfully submitted and would be delivered to recipients shortly.