FilterableTable uses client-side JavaScript to hide or show table rows based on characters typed by a user. Simply type the characters to be used for filtering the table and press enter to focus the table; press escape to show all table rows.
This gem is currently in alpha mode; use at your own risk. It’s been tested under Safari only; IE is not currently supported.
-
Install the gem:
gem install filterable_table
-
Add the following to your application’s Rakefile:
require 'filterable_table/tasks'
-
Install the supporting code:
rake filterable_table:install
-
Add this line to your app/helpers/application_helper.rb file:
include FilterableTable::Helper
Usage is simple. First, set the class name of each table row in your table to ‘filterable’. Then insert the filter_table method just before where your table appears in the view.
Example:
<%= filter_table -%> <table> <thead> <tr> <th>Name</th> <th>URL</th> </tr> </thead> <tbody> <%- @foos.each do |foo| -%> <tr class="filterable"> <td><%= foo.name -%></td> <td><%= foo.url -%></td> </tr> <%- end -%> </tbody> </table>
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Corey Ehmke / SEO Logic. See LICENSE for details.