[Betternestedset-talk] Sortable Sets
Jeremy Nicoll
jnicoll at gnexp.com
Wed Mar 19 18:04:09 EDT 2008
No thoughts at the moment, but if you run into any problems I'll see
if I can help you. FYI, I have not used the two components that you are
using together - mostly I've just used better_nested_set. 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.
*Jeremy Nicoll*
www.gnexp.com <http://www.gnexp.com>
(801) 783-3831
John-Paul Bader wrote:
> 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.
>
> Any thoughts on that ?
>
> Kind regards, John
>
> On 19.03.2008, at 20:45, Jeremy Nicoll wrote:
>> Hello John-Paul,
>>
>> I've done this in a recent project. 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. 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:
>>
>> ------------------------------------------------------------------------
>> def move_to_parent_location(parent, location)
>> parent = nil if parent == 0
>> parent = parent === self.class ? parent :
>> self.class.find(parent) if parent
>> children = parent ? parent.children : self.class.roots
>>
>> if children.length > 0
>> ord = location.to_i
>> if ord > children.length
>> self.move_to(children.last, :right)
>> elsif children[ord] != self
>> self.move_to(children[ord], :left)
>> end
>> elsif parent
>> self.move_to(parent, :child)
>> end
>> end
>> ------------------------------------------------------------------------
>>
>>
>> <logo_sig.jpg>
>> *Jeremy Nicoll*
>> www.gnexp.com <http://www.gnexp.com>
>> (801) 783-3831
>>
>>
>> John-Paul Bader wrote:
>>> 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 <ul> 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 => true
>>>
>>> http://whynotwiki.com/Rails_/_Sortable_trees
>>>
>>> On the same page there is a link to the rubyonrails wiki stating that
>>> there is a fix expecially for better_nested_set. http://dev.rubyonrails.org/ticket/7807
>>>
>>> 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
>>> Betternestedset-talk at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/betternestedset-talk
>>>
>>>
>> _______________________________________________
>> Betternestedset-talk mailing list
>> Betternestedset-talk at rubyforge.org
>> <mailto:Betternestedset-talk at rubyforge.org>
>> http://rubyforge.org/mailman/listinfo/betternestedset-talk
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Betternestedset-talk mailing list
> Betternestedset-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/betternestedset-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080319/dd180f07/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo_sig.jpg
Type: image/jpeg
Size: 2312 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080319/dd180f07/attachment.jpg
More information about the Betternestedset-talk
mailing list