views:

15

answers:

0

I am using jqgrid with Ruby on Rails using the 2dc_jqgrid plugin -- 2dc_jqgrid details).

By default, the plugin seems to take information directly from the fields in your model and display them in the resulting table. For instance:

books = Book.find(:all) do
  if params[:_search] == "true"

    id =~ "%#{params[:id]}%" if params[:id].present?

    model =~ "%#{params[:name]}%" if params[:model].present?

    manufacturer =~ "%#{params[:publisher]}%" if params[:publisher].present?

  end
  paginate :page => params[:page], :per_page => params[:rows]      
  order_by "#{params[:sidx]} #{params[:sord]}"
end
if request.xhr?
  render :json => books.to_jqgrid_json([:id,:name,:publisher], params[:page], params[:rows], camera_grids.total_entries) and return
end

With this default setup, the manufacturer's ID will be displayed in the resulting table (e.g., 12). I want to display the publisher's name. A book belongs to a publisher so I'd like to specify book.publisher.name. I am not sure how or where I can do this with 2dc_jqgrid.

Any suggestions? Thank you.