Bogdan Gusiev's blog

How to make good software for people


New release of Datagrid: Mongoid, Rails Engines and HTML columns support
10 Jan 2012

Datagrid version 0.5.0 has been released.

Datagrid is a Ruby on Rails plugin that helps you to build and represent table-like data with:

  • Customizable filtering
  • Columns
  • Sort order
  • Localization
  • Export to CSV

Here are some major features from new release.

Mongoid support

Previously Datagrid supported only ActiveRecord ORM. Now Mongoid is also available: see the demo.

New datagrid driver architecture allows to add yet another ORM in less then 40 lines of code.

HTML columns

In order to use view helpers to render columns You can use :html option. This will call column block in the view context:

column(:completed, :html => true) { |asset| asset.completed? ? image_tag("green.gif") : image_tag("red.gif") }
# or do it in partial
column(:actions, :html => true) { |asset| render :partial => "admin/assets/actions", :object => asset }

Table customization with Rails Engines

Rails Engines allows you to embed views into Rails plugins and make them customizable. If You need serious customization of datagrid <table> and HTML Columns doesn’t help, you can customize datagrid internal views by running:

rake datagrid:copy_partials

This will create the following files in your Rails root directory:


|~app/
| ~views/
|   ~datagrid/
|     |-_head.html.erb
|     |-_row.html.erb
|     |_table.html.erb

Now You are able to customize whatever You want.

datagrid gem rails changelog