Leave a comment

Implementing Data Table In Rails


Nice writeup of using Datatables in Rails app. I use this gem myself in a CRM. Easy to use and looks great out of the box. I just wish it would work with mongodb 😦

Ruby on Rails

Data Table help us to turn a plain HTML table into one with pagination, sorting and searching and all through JavaScript. It has better user interface and provides many options to the user.

You  can learn more about data tables from its official website http://datatables.net . Here is a simple example of integrating data table in your rails app.

Step 1

Add the gem in your gem file

gem 'jquery-datatables-rails', git: 'git://github.com/rweng/jquery-datatables-rails.git'

Run the bundle install.

Step 2

We can now set DataTables up with the asset pipeline.

In your application.js add the following line

//= require dataTables/jquery.dataTables

In your application.css add the following line

*= require dataTables/jquery.dataTables

Step 3

Now we have installed the data table in the application.In order to display the data table effect in your listing page ,modify it like below

<table id="product_lists"> <thead>   <tr>     <th>Product Name</th>     <th>Category</th>     <th>Price</th>   </tr>…

View original post 89 more words

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: