Using Rails 3.1 with DataTables

In Rails 3.1, what recommended pearl integrates with DataTables ?

+6
source share
4 answers

I use the pearl jquery-datatables-rails with bootstrap (gem) and it is beautiful. The episode railscast on it is wonderful - but do not put the gem in your asset group or it will not work when deployed to heroku (since the asset group is not used in production).

Put this line in your gemfile:

 gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails' 

and run:

 bundle install 

Also, be sure to put this line in application.rb:

 config.assets.initialize_on_precompile = false 

Add this to your application.js

 //= require dataTables/jquery.dataTables 

And this if you use the download:

 //= require dataTables/jquery.dataTables.bootstrap 

Add this to your application.css:

 *= require dataTables/jquery.dataTables 

Or this if you use download:

 *= require dataTables/jquery.dataTables.bootstrap 

And if you use bootstrap, add this to your js.coffee file for your controller, you use datatables in:

If you use liquid containers:

 #// For fluid containers $('#dashboard').dataTable({ "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap" }); 

If you use containers with a fixed width:

 #// For fixed width containers $('.datatable').dataTable({ "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap" }); 
+10
source

In Rails Bates' RailsCast on the topic ( http://railscasts.com/episodes/340-datatables ) it uses jquery-datatables-rails ( https://github.com/rweng/jquery-datatables-rails )

+2
source

I have not used it myself, but this is the one that is available: https://github.com/gryphon/simple_datatables .

0
source

The following gem link may be relevant: https://github.com/artellectual/rails-datatables

This gemstone is the fork of the simplest hard drive (mentioned by Allan), but it also supports pagination using kaminari and searching for table data using ajax using the meta search stone.

0
source

Source: https://habr.com/ru/post/897001/


All Articles