Gem to create tables grids with sortable columns and filters
Gem to create tables grids with sortable columns and filters
Datagrid Version 2.0.0 is here.
Migration Guide. A really mighty and flexible ruby library that generates reports including admin panels, analytics and data browsers:
Datagrid DEMO application is available live! Demo source code.
In order to create a grid:
class UsersGrid { joins(:group).order(groups: :name) }) do |user|
user.name
end
column(:active, header: "Activated") do |user|
!user.disabled
end
endBasic grid api:
…In order to create a report, you need to define:
Default scope of objects to filter and display.
In common case it is ActiveRecord::Base (or any other supported ORM)
subclass with some generic scopes like:
scope do
User.includes(:group)
endEach filter definition consists of:
Datagrid supports different type of filters including:
Each column is represented by name and code block to calculate the value.
column(:activated, header: "Active", order: "activated", after: :name) do
self.activated?
endSome formatting options are also available. Each column is sortable.
Datagrid has a builtin generator:
rails g datagrid:scaffold skillsThat gives you some code to play with out of the box:
create app/grids/skills_grid.rb
create app/controllers/skills_controller.rb
create app/views/skills/index.html.erb
route resources :skills
insert app/assets/stylesheet/application.cssIn order to get a control on datagrid built-in views run:
rails g datagrid:viewsAll advanced frontend things are described in:
If you have a question of any kind, just make an issue and describe your problem in details.
If you are interested in contributing to this project, please follow the instructions here.
Like datagrid?
Follow the repository on GitHub.
Read author blog.
No open issues yet, or sync has not completed.