原文参见我另一个博客:http://caok.github.com/blog/2012/08/07/jquery-columnmanager-plugin-and-rails-settings-cached/
在平时页面显示表格时,容易出现要显示的字段过多,而在一页的范围内无法完全显示的困境。通过juery columnanager可以实现显示和隐藏的效果,再通过rails-settings-cached将其与个人偏好设置相关联,使得更加人性化。
安装rails-settings-cached
Edit your Gemfile:
gem "rails-settings-cached"
Generate your settings:
$ rails g settings
Now just put that migration in the database with:
rake db:migrate
Settings may be bound to any existing ActiveRecord object. Define this association like this: Notice! is not do caching in this version.
class User < ActiveRecord::Base
include RailsSettings::Extend
end
安装jQuery columnManager plugin
下载地址:jquery.columnmanager.zip 我这使用的是里面的jquery.columnmanager.pack,添加至项目的application.js中
//= require jquery.columnmanager.pack
两者的配合使用
页面上调用
div id="targetcol">