Skip to content
SlickGrid integration for Rails 4.x
Ruby Shell
Pull request Compare This branch is 2 commits ahead, 7 commits behind liquidm:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


slickgrid-rails is a simple gem to add SlickGrid vendor files to the Rails asset pipeline. It also provides a simple SlickGrid::Table class to render JSON output suitable for the Grid/DataView.


Add this line to your application's Gemfile:

gem 'slickgrid-rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slickgrid-rails


To use the basic grid functionality you just need to include the slick.js file in your Sprocket manifest:

//= require slick

The above example will include all required jQuery dependencies and core.js/grid.js from SlickGrid. To use one of the more advanced example modules simply add them to your manifest:

//= require slick/dataview
//= require slick/editors
//= require slick/formatters

Rails Table Helper

A simple table helper is included to generate SlickGrid compatible JSON output:

require "slickgrid/table"

class UsersTable < SlickGrid::Table
  column :name
  column :email
  column :last_login

To render a list of all users add the following to your controller:

class UsersController < ApplicationController
  def index
    respond_with(@users) do |format|
      format.json { render :json => }

The SlickGrid::Table class will render columns for each model instance by simply calling the column methods on the instance. If you want to customize the output, specify a custom generator function:

class UsersTable < SlickGrid::Table
  column :name, generator: ->(obj) { "#{obj.first_name} #{obj.last_name}" }
  column :email
  column :last_login

Rails Model Support

This gem also replaces the example RemoteModel (which can only load data from to support loading and updating standard Rails REST models. First, include the class into your manifest:

//= require slick/remotemodel

Then update your table definition to include a path column for each instance:

class UsersTable < SlickGrid::Table
  column :path, generator: ->(obj) { user_path(obj) }

Finally wire up all the grid events (example taken from the requirejs-controllers gem):

initGrid: (@selector, @columns, @options) ->
  @dataView = new Slick.Data.DataView()
  @grid = new Slick.Grid(@selector, @dataView, @columns, @options)
  @model = model = new Slick.Data.RemoteModel()

initLoader: ->
  @model.onDataLoading.subscribe (e, args) =>

  @model.onDataLoaded.subscribe (e, args) =>

  @model.onDataLoadedSuccess.subscribe (e, args) =>

  @model.onDataLoadedError.subscribe (e, args) =>
    alert("failed to load data from server")

initWriter: ->
  @model.onDataWriting.subscribe (e, args) =>

  @model.onDataWritten.subscribe (e, args) =>

  @model.onDataWrittenSuccess.subscribe (e, args) =>

  @model.onDataWrittenError.subscribe (e, args) =>
    alert("failed to write data on server")

  @grid.onCellChange.subscribe (e, args) =>

Update SlickGrid

To upgrade SlickGrid version just run

rake slickgrid:update

It will clone the current SlickGrid master and will copy all javascript and stylesheet files into this repository. Don't forget to update the gemspec version!


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request


Bootstrap integration is from

Something went wrong with that request. Please try again.