Fivell Fivell - 4 months ago 62
Ruby Question

Can you recommend good data grid class/gem for Ruby on Rails?

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

Answer

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
Comments