acts_as_flexigrid¶ ↑
ActiveRecord plugin to use easily Flexigrid that is jQuery plugin for grid table
Installation¶ ↑
gem install acts_as_flexigrid
How to use¶ ↑
-
Download Flexigrid from flexigrid.info/ and place javascript and css files.
-
Include to models
class Site < ActiveRecord::Base include ActsAsFlexigrid end
-
Get json response for Flexigrid
class SitesController < ApplicationController def index @sites = Site.where({...}) respond_to do |format| format.html format.json do if params.delete(:flexigrid).present? @site = @sites.flexigrid(params) end render :json => @sites end end ...
-
Set javascript and view
application.js
$("#sites-grid").flexigrid({ method: "GET", url: "/sites.json?flexigrid=true", dataTyep: "json", colModel: [ {display: 'Name', name: 'name, sortable: true}, ... ], searchitems: [ {display: "Name", name: 'name, isdefault: true}, .... ], sortname: "name", sortorder: "asc", usepager: true, rp: 10 })
view / app/views/sites/index.html.erb
<div id="sites-grid"></div>
Copyright¶ ↑
Copyright © 2011 Akihiro Matsumura. See LICENSE for details.