<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Oh, I think I
know what you are saying now.&nbsp; Actually, it's a bit more hairy than
that because with nested sets, the order is determined by the "lft"
column. You cannot change this column directly, as ANS (and as such,
BNS) uses this to keep track of where everything belongs. If you don't
care about the ordering of the children when retrieved by the BNS
methods then you might be able to do the method that you are thinking.&nbsp;
Something to consider.<br>
<br>
</font></font>
<div class="moz-signature">
<div style="line-height: 125%;"> <img
 src="cid:part1.02010904.04080801@gnexp.com" height="49" width="136"><br>
<span style="font-family: Arial,Helvetica,sans-serif; font-size: 9pt;"><b>Jeremy
Nicoll</b><br>
<a href="http://www.gnexp.com">www.gnexp.com</a><br>
(801) 783-3831 </span>
</div>
</div>
<br>
<br>
John-Paul Bader wrote:
<blockquote
 cite="mid:2EEBAC5B-80AD-490B-8B04-698BE130C9B7@medienhaus.udk-berlin.de"
 type="cite">Well I think actually these are two seperate functions.
One function is to put nodes on different positions in the tree and the
other one would be ordering the nodes within a parent node. Tomorrow at
work I'll try that approach and let you know how it went.
  <div><br>
  </div>
  <div>Kind regards, John<br>
  <div><br>
  <div>On 19.03.2008, at 23:04, Jeremy Nicoll wrote:<br
 class="Apple-interchange-newline">
  <blockquote type="cite">
    <div bgcolor="#ffffff" text="#000000"> <font size="-1"><font
 face="Helvetica, Arial, sans-serif">&nbsp;&nbsp;&nbsp; No thoughts at the moment, but
if you run into any problems I'll see if I can help you.&nbsp; FYI, I have
not used the two components that you are using together - mostly I've
just used better_nested_set.&nbsp; Ordering things in a list is pretty easy
and so I've always just done my own code because I've felt the other
helpers just get in my way.<br>
    <br>
    </font></font>
    <div class="moz-signature">
    <div style="line-height: 125%;"> <span>&lt;logo_sig.jpg&gt;</span><br>
    <span
 style="font-family: Arial,Helvetica,sans-serif; font-size: 9pt;"><b>Jeremy
Nicoll</b><br>
    <a moz-do-not-send="true" href="http://www.gnexp.com">www.gnexp.com</a><br>
(801) 783-3831 </span> </div>
    </div>
    <br>
    <br>
John-Paul Bader wrote:
    <blockquote
 cite="mid:BD7CFD8B-BA1A-4B47-B844-A7E29E8664F3@medienhaus.udk-berlin.de"
 type="cite">
      <div>After lots of reading I think the best way is to use simple
draggables and droppables. After the drop i'll move the dragged node to
the dropped one with move_to_child_of and after that i'll redraw the
tree.</div>
      <div><br>
      </div>
      <div>Any thoughts on that ?&nbsp;</div>
      <div><br>
      </div>
      <div>Kind regards, John</div>
      <br>
      <div>On 19.03.2008, at 20:45, Jeremy Nicoll wrote:<br
 class="Apple-interchange-newline">
      <blockquote type="cite">
        <div bgcolor="#ffffff" text="#000000"> <font size="-1"><font
 face="Helvetica, Arial, sans-serif">Hello John-Paul,<br>
        <br>
&nbsp;&nbsp;&nbsp; I've done this in a recent project.&nbsp; Basically the way I do it is
check to see what order the a selected item in a list is in, and then
move that item before/after a child node in the target parent based off
this information.&nbsp; It's a bit complicated, but it's doable. I monkey
patched the module SymetrieCom::Acts::NestedSet to include the
following method to help me with this scenario:<br>
        <br>
        </font></font>
        <hr size="2" width="100%"><font size="-1"><font
 face="Helvetica, Arial, sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def
move_to_parent_location(parent, location)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parent = nil if parent == 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parent = parent === self.class ? parent :
self.class.find(parent) if parent<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; children = parent ? parent.children : self.class.roots<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if children.length &gt; 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ord = location.to_i<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ord &gt; children.length<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(children.last, :right)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif children[ord] != self<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(children[ord], :left)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif parent<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(parent, :child)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br>
        </font></font>
        <hr size="2" width="100%"><font size="-1"><font
 face="Helvetica, Arial, sans-serif"><br>
        <br>
        </font></font>
        <div class="moz-signature">
        <div style="line-height: 125%;"> <span>&lt;logo_sig.jpg&gt;</span><br>
        <span
 style="font-family: Arial,Helvetica,sans-serif; font-size: 9pt;"><b>Jeremy
Nicoll</b><br>
        <a moz-do-not-send="true" href="http://www.gnexp.com">www.gnexp.com</a><br>
(801) 783-3831 </span> </div>
        </div>
        <br>
        <br>
John-Paul Bader wrote:
        <blockquote
 cite="mid:9B3FAD14-7316-43A6-A318-1B45B250CFD8@medienhaus.udk-berlin.de"
 type="cite">
          <pre wrap="">Hey there,

I just subscribed so i hope this question isn't redundant.

I'm trying to implement a sortable nested set.

I've already got an application with better_nested_set in place. I  
also got a nice nested &lt;ul&gt; rendering for my tree. No I'd be able to  
drag an drop / sort elements across the set.

I found this Wiki entry which says that it wouldn't be a good idea in  
general to use sortable.create with :tree =&gt; true

<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://whynotwiki.com/Rails_/_Sortable_trees">http://whynotwiki.com/Rails_/_Sortable_trees</a>

On the same page there is a link to the rubyonrails wiki stating that  
there is a fix expecially for better_nested_set. <a
 moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://dev.rubyonrails.org/ticket/7807">http://dev.rubyonrails.org/ticket/7807</a>

My question would be what your experiences are. Is there a good way to  
implement a sortable / draggable better_nested_set ? If not do you  
have any suggestions, thoughs on this ?

Thanks and kind regards,

John (Berlin / Germany)
_______________________________________________
Betternestedset-talk mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a>

  </pre>
        </blockquote>
        </div>
_______________________________________________<br>
Betternestedset-talk mailing list<br>
        <a moz-do-not-send="true"
 href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>
        <a moz-do-not-send="true"
 href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br>
      </blockquote>
      </div>
      <br>
      <pre wrap=""><hr size="4" width="90%">
_______________________________________________
Betternestedset-talk mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
 href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a>
  </pre>
    </blockquote>
    </div>
_______________________________________________<br>
Betternestedset-talk mailing list<br>
    <a moz-do-not-send="true"
 href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br>
    <a moz-do-not-send="true"
 href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br>
  </blockquote>
  </div>
  <br>
  </div>
  </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Betternestedset-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a>
  </pre>
</blockquote>
</body>
</html>