javascript rails

Gridify - A Ruby wrapper and Rails plugin for jqGrid

Gridify is a Ruby wrapper and Rails plugin for jqGrid.

jqGrid is a rich featured data grid built with the jQuery javascript library.

Gridify defines a simplified, more consistent API for jqGrid rather than directly emulate the jqGrid api and options in Ruby.

Gridify tries to respect the MVC (model-view-controller) architecture of your application. This is challenging because grid features span all three areas: it’s clearly part of the "view" as it mostly resides in the browser; columns in the table often directly map to columns in the model (database); and grid’s ajax requests are handled by controllers. Gridfy gives you some flexibility in managing grids within MVC.


Lets say we have an ActiveRecord model "Note" which we want to display in a grid.

In app/models/note.rb,

  class Note < ActiveRecord::Base

In the NotesController,

  def index
if request.xhr?
records = Note.find_for_grid :grid, params
render :xml => Note.grid.encode_records(records)
@grid = Note.grid

In the app/views/notes/index.html.erb,

  <%= @grid %>
<h1>Notes Grid<h1>
<table id="notes_grid"></table>
<div id="notes_grid_pager"></div>

In this example, gridify creates a default grid named "grid" for the Notes model. In the controller, the #index html action supplies the @grid object used by the view; the #index xml action responds to request params with the encoded data. In the view, @grid.to_s generates the javascript code needed for the grid, which populates the table and pager div.


The project source code and more documentation is on github at




by guest on Jan 19, 2010



can i use the will_paginate plugin ?

by admin on Jan 19, 2010


<p>hi, if you want to use will_paginate then dont use the #find_for_grid method. Instead you'll need to inerpret the params passed by jqgrid in your controller. </p> <p>But I'm not sure why you'd want to use will_paginate. find_for_grid does pagination, and with jqgrid you dont use the will_paginate view helpers.</p>

by Satish on Mar 30, 2010


Thanks for the awesome work.

Is there any way to use inline edit with this plugin?

by admin on Mar 30, 2010


@satish I havent added inline edit to the ruby wrapper so you'd just call it directly as described in the jqgrid docs.

by omar on May 11, 2010


Hi Linoj, I have been playing with the plugin with the example 2. However I get an error with the last statement in the method index of the controller begin @grid = Note.grid :mylist end error wrong number of arguments (1 for 0) end*** I put a comma before :mylist. the error didnot show anymore but the grid is not showing as well Thanks for your help

by Eric on May 31, 2010

Feature Request

Hey, thanks for the plugin, works great for some things I need.

I do, however, have a feature request. I am looking into adding it myself, but I am a ruby nubi. I would like to somehow specify it to be able to lookup relations and display their data. For ex:

I have a table for Users and their favorite colors are listed in Colors. The Users has a color_id column to link it. Currently it will just display the value of color_id. I would like for it to show instead. Not sure how hard this would be to add, but if you can steer me in the right area of your code to try to add something like this, I would appreciate it.

by Anita Graham on Jun 09, 2010

pluralize and tableize seem to get the name wrong

Hi, I am trying to implement gridify on a fairly simple application. The first thing I'm trying to gridify is called 'person' and has a table name of people. Gridify tries to turn this into peoples, so the js includes this: jQuery(document).ready(function(){ grid = jQuery("#peoples_grid").jqGrid({"url":"/peoples","restful":true,"postData":{"gri d":"grid"},..... etc but there is no url called /peoples, just one called people. Any thoughts on this?

thanks, Anita

by Anita Graham on Jun 11, 2010

basic ununderstanding here: can you help?

As mentioned in my previous post I am trying to gridify a table called People, which has persons as records. Having 'fixed' the previous problem (by removing one of tableize and pluralize) I have a very basic problem: no data gets added to my grid. 1. The grid appears on the page 2. The pager has the correct information in it: I return 49 records and the pager indicates that it is page 1 of 5. If I change the rows/page, the pager changes the total number of pages. BUT 3. The rhs of the pager says 'No records to view'. 4. Using Firebug I can see my data returned as XML in the Response.

What happens to it after that?

I can't seem to track down what is going on after that.

THank you for any insight you can offer.


by Anita on Jun 14, 2010

Problem solved...

I fixed my own problems in the end. They were all related to the pluralize.tableize issue (which I think is still an issue), but after that it was all to do with me.

Thanks for Gridify, which is now making my page look beautiful.

by Anita on Jun 15, 2010

Re: Feature Request

Did you get a response to this? Now that my grid is working, I have a couple of different relations I'd like to indicate on the grid. Alternatively I'd like to add a column which let the user go to a full edit page for the row, as I already have the relationships working there.

by Anita on Jun 15, 2010


How does gridify deal with simple relationships like "has one" and "belongs to"?

by admin on Jun 15, 2010


Hi Anita, I'm on vacation through next week and we can have a conversation after that about your questions. And feel free to email me directly rather than using these comments :) jonathan at parkerhill com

by hospital on Apr 17, 2011


Thanks for this very useful info you have provided us. I will bookmark this for future reference and refer it to my friends. More power to your blog

<a href="">Hospital</a> <a href="">Porn</a> <a href="">mp3</a>

by Fashion on Aug 02, 2011

Online Fashion

Good article more useful to me, I will continue to pay attention, I hope you lot just my site

by vikram kumar mishra on Dec 28, 2011


I am a newbie, so can you please tell me how to install it because i tried to install it using "rails plugin install git://" and "rails plugin install" but it is simply creating a empty folder named "2dc_jqgrid" inside app/vendors/plugins directory.

Please suggest me how to install it properly. I am using rails 3.1.3, ruby 1.9.2


by assemqwtyfr on Jul 23, 2016

o9fzo8st - serevent - buy atenolol - lexapro 10mg

New Comment

markdown formatting permitted