Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

datagrid

> 后端框架
Open source

Gem to create tables grids with sortable columns and filters

1.1K stars0 likes3 views
WebsiteGitHub

About

Gem to create tables grids with sortable columns and filters

Datagrid

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:

  • Filtering
  • Columns
  • Sort order
  • Localization
  • Export to CSV

ORM Support

  • ActiveRecord
  • Mongoid
  • MongoMapper
  • Sequel
  • Array (in-memory data of smaller scale)

Datagrid Philosophy

  1. Expressive DSL complements OOD instead of replacing it.
  2. Extensible in every way while providing a lot of defaults.
  3. If your ORM supports that, datagrid also supports that!

Documentation

  • Rdoc - full API reference
  • Scope - working with datagrid scope
  • Columns - defining datagrid columns
  • Filters - defining datagrid filters
  • Frontend - building a frontend
  • Configuration - configuring the gem

Live Demo

Datagrid DEMO application is available live! Demo source code.

Example

In order to create a grid:

ruby
class UsersGrid  { joins(:group).order(groups: :name) }) do |user|
    user.name
  end
  column(:active, header: "Activated") do |user|
    !user.disabled
  end

end

Basic grid api:

…

Grid DSL

In order to create a report, you need to define:

  • scope of objects to look through
  • filters that will be used to filter data
  • columns that should be displayed and sortable (if possible)

Scope

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:

ruby
scope do
  User.includes(:group)
end

More about scope

Filters

Each filter definition consists of:

  • name of the filter
  • type that will be used for value typecast
  • conditions block that applies to defined scope
  • additional options

Datagrid supports different type of filters including:

  • text
  • integer
  • float
  • date
  • datetime
  • boolean
  • xboolean - the select of "yes", "no" and any
  • enum - selection of the given values
  • string
  • dynamic - build dynamic SQL condition

More about filters

Columns

Each column is represented by name and code block to calculate the value.

ruby
column(:activated, header: "Active", order: "activated", after: :name) do
  self.activated?
end

Some formatting options are also available. Each column is sortable.

More about columns

Front end

Using Generator

Datagrid has a builtin generator:

rails g datagrid:scaffold skills

That 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.css

Customize Built-in views

In order to get a control on datagrid built-in views run:

bash
rails g datagrid:views

Advanced frontend

All advanced frontend things are described in:

Frontend documentation

Questions & Issues

If you have a question of any kind, just make an issue and describe your problem in details.

Contribution

If you are interested in contributing to this project, please follow the instructions here.

Self-Promotion

Like datagrid?

Follow the repository on GitHub.

Read author blog.

License

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubyactiverecordgemgridmongoid

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架