Selecting a node, its siblings, and the siblings of its ancestors (including the ancestors) #61

brendon opened this Issue Jul 8, 2011 · 1 comment


None yet

1 participant


Hopefully the title says it all. I have a special type of indexbar that shows a drilled down view of a node and its surroundings. Essentially it shows the current node, its siblings surrounding it in order, and then a certain level of its ancestors from itself (e.g. parent, grandparent). It also shows those ancestors siblings surrounding it.

It doesn't show any of the other siblings descendants however and that's where I've come unstuck with trying to generate a query for this. Do you have any hints? I think I might have to resort to firstly fetching the path for a node (to a certain height), and then looping over each of those nodes and fetching their siblings into an array and somehow sorting it.

Hope you can help :D



I ended up selecting the column nodes first, then iterating over them to form an array of siblings. I then used the arrange_nodes class method to arrange them properly :) Worked a treat!

unarranged_component_instances = selected_component_instance.path.from_depth(top_level).inject( do |component_instances, component_instance|
  component_instances << component_instance.siblings

@brendon brendon closed this Jul 10, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment