[Betternestedset-talk] Trouble with tree view
Mark.noten
mark.noten at itfc.be
Fri May 25 04:12:31 EDT 2007
Some extra information:
manager.all_children = child_agents
And agents.shift should be child_agents.shift
Kind regards,
Mark
--------- Original Message --------
From: betternestedset-talk at rubyforge.org
To: betternestedset-talk at rubyforge.org <betternestedset-talk at rubyforge.org>
Subject: [Betternestedset-talk] Trouble with tree view
Date: 25/05/07 00:23
> Hi all,
>
> I'm struggling a bit with displaying a subtree with all the child nodes of
a
> node. A node in this case is an Agent model extending ActiveRecord::Base
and
> using acts_as_nested_set :scope => :product_id.
>
> I would like to generate the below HTML code that displays a tree. The
ASCII
> connectors can easily be replaced by icons.
>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap><b>node 1</b></td></tr>
> <tr><td>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap>|-</td><td nowrap>node
1.1</td></tr></table>
> </tr>
> <tr>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap>|-</td><td nowrap>node
1.2</td></tr></table>
> </tr>
> <tr><td>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap>|&nbsp;&nbsp;</td><td
nowrap>|-</td><td nowrap>node
> 1.2.1</td></tr></table>
> </tr>
> <tr>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap>|&nbsp;&nbsp;</td><td
nowrap>-</td><td nowrap>node
> 1.2.2</td></tr></table>
> </tr>
> </table>
> </td></tr>
> <tr>
> <table border=0 cellspacing=0 cellpadding=0>
> <tr><td nowrap>-</td><td nowrap>node
1.3</td></tr></table>
> </tr>
> </table>
> </td></tr>
> <tr><td nowrap>node 2</td></tr>
> </table>
>
> I have this method defined in the AgentsHelper module:
>
> def show_agents_tree(current_agent, child_agents)
> html = "<table class="agent-tree">n"
> html += "<tr><td
nowrap>#{agent_link(current_agent)}</td></tr>n"
> if !agents.empty?
> html += "<tr><td>n"
> html += show_agents_tree(agents.shift, child_agents)
> html += "</td></tr>n"
> end
> html += "</table>n"
> end
>
> It generates HTML code that just displays each agent as a child of the
> previous agent. Can anyone help me to get the right level (O, 1, 2, ...)
> dependent indentation working? Any help is appreciated.
>
> Thanks,
>
> Mark
> _______________________________________________
> Betternestedset-talk mailing list
> Betternestedset-talk at rubyforge.org
> http://rubyforge.org/mailman/listinfo/betternestedset-talk
>
>
________________________________________________
Message sent using UebiMiau 2.7.10
More information about the Betternestedset-talk
mailing list