6

Can you recommend good data grid class/gem for Ruby on Rails? Like http://code.google.com/p/zend-framework-datagrid/ for ZF

Fivell
  • 11,829
  • 3
  • 61
  • 99

4 Answers4

10

You can also try datagrid gem. That is focused not only grids with columns but also filters.

class SimpleReport

  include Datagrid

  scope do
    User.includes(:group)
  end

  filter(:category, :enum, :select => ["first", "second"])
  filter(:disabled, :eboolean)
  filter(:confirmed, :boolean)
  filter(:group_id, :integer, :multiple => true)
  integer_range_filter(:logins_count, :integer)
  filter(:group_name, :string, :header => "Group") do |value|
    self.joins(:group).where(:groups => {:name => value})
  end


  column(:name)
  column(:group, :order => "groups.name") do |user|
    user.name
  end
  column(:active, :header => "Activated") do |user|
    !user.disabled
  end
end
Bogdan Gusiev
  • 8,027
  • 16
  • 61
  • 81
4

Not sure if this is what you are looking for but checkout https://github.com/wice/wice_grid

SergioB
  • 193
  • 1
  • 5
3

If you are looking for a powerful client-side grid, supporting pagination, sorting, grouping, editing, export to Excel, PDF, etc, you can check Shield UI's Grid component.

Here's a tutorial on how to integrate it in Rails.

Vladimir Georgiev
  • 1,949
  • 23
  • 26
0

If you are looking for things like pagination, ordering, sorting etc, then rails does all this automatically.

So, for example if you wanted to sort all row by a particular column, then the title of that column could simply be a link that sorted the results by that column and then re rendered the grid.

So if you want to build a data grid that isn't AJAXy then this is pretty simple. If you are looking for a way to do it with XHR requests then you can use jQuery to make requests in the background.

As fas as a gem that does all this automatically, I couldn't find one, but I can't see why you couldn't do it yourself easily with the foundations that rails provides.

TheDelChop
  • 7,938
  • 4
  • 48
  • 70