[Rails] Datagrid Helper

"Luis G. Gómez" lgomez at vfxnetwork.com
Thu Dec 16 06:21:23 GMT 2004


Check this out: http://tablehelper.rubyforge.org/

Demetrius Nunes wrote:
> I was wondering if anybody crafted a "Datagrid" helper that would 
> receive a array of object, column definitions and other stuff and would 
> render a nice table.
> 
> I built one, that works well, but it is ugly as hell. Here is an example 
> of usage:
> 
> <%
> dg = DataGrid.new(@contexts, self)
> dg.row_count = { :label => "context" }
> dg.actions << { :eval => "link_to('[Add New Context]', :action => 'new')" }
> dg.actions << { :eval => "link_to('[Clear All Contexts]', :action => 
> 'clear')" }
> dg.columns << { :label => "Name", :eval => "item.name" }
> dg.columns << { :label => "Type", :eval => "item.type.to_s" }
> dg.columns << { :eval => "link_to('[Edit]', :action => 'edit', :id => 
> item.id)" }
> dg.columns << { :eval => "link_to('[Delete]', :action => 'delete', :id 
> => item.id)" }
> %>
> <%= dg.render %>
> 
> It renders a nicely alternating color table, with 4 columns (2 for data 
> and 2 for row actions: edit and delete), a row count and 2 global actions.
> 
> Anybody has come up with something better?
> 
> Regards,
> Demetrius
> 
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
> 


More information about the Rails mailing list