Coder Social home page Coder Social logo

jquery-datatables-rails's Introduction

jquery-datatables-rails

Gem Version

This gem packages the jQuery DataTables plugin for easy use with the Rails 3.1+ asset pipleine. It provides all the basic DataTables files, and a few of the extras.

Important

The current gem is released without updated plugins.

jQuery DataTables renamed the parameters names, if you are updating, please take a look http://www.datatables.net/upgrade/1.10-convert

If you encounter any errors, please fork the repository, update the plugin files and send a pull-request.

Upgrade Notes

1 - For people upgrading to 3.x.x who are using the responsive extension. Due to an error displaying the plus icon in a recent version of this gem, the responsive code has now changed and uses the DataTables responsive extension instead. This requires some changes to your responsive configuration. See the Responsive Installation section below and follow the link.

General Installation

1 - Add to your Gemfile:

gem 'jquery-datatables-rails', '~> 3.4.0'

2 - Install the gem:

bundle install

3 - Run the install generator:

$ rails generate jquery:datatables:install

This will add to the corresponding asset files

# app/assets/javascripts/application.js
//= require dataTables/jquery.dataTables
# app/assets/stylesheets/application.css
*= require dataTables/jquery.dataTables

Twitter Bootstrap 2 Installation

1 - Complete steps 1-2 of the General Installation

2 - Run the install generator:

$ rails generate jquery:datatables:install bootstrap2

This will add to the corresponding asset files

# app/assets/javascripts/application.js
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/2/jquery.dataTables.bootstrap

# app/assets/stylesheets/application.css
*= require dataTables/bootstrap/2/jquery.dataTables.bootstrap

3 - Initialize your datatables using one of these options:

// For fluid containers
$('.datatable').DataTable({
  dom: "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
  pagingType: "bootstrap"
});

// For fixed width containers
$('.datatable').DataTable({
  dom: "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
  pagingType: "bootstrap"
});

Twitter Bootstrap 3 Installation

1 - Complete steps 1-2 of the General Installation

2 - Run the install generator:

$ rails generate jquery:datatables:install bootstrap3

This will add to the corresponding asset files

# app/assets/javascripts/application.js
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap

# app/assets/stylesheets/application.css
*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap

3 - Initialize your datatables using these option:

$('.datatable').DataTable({
  // ajax: ...,
  // autoWidth: false,
  // pagingType: 'full_numbers',
  // processing: true,
  // serverSide: true,

  // Optional, if you want full pagination controls.
  // Check dataTables documentation to learn more about available options.
  // http://datatables.net/reference/option/pagingType
});

Zurb Foundation Installation

1 - Complete steps 1-2 of the General Installation

2 - Run the install generator:

$ rails generate jquery:datatables:install foundation

This will add to the corresponding asset files

# app/assets/javascripts/application.js
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.foundation

# app/assets/stylesheets/application.css
*= require dataTables/jquery.dataTables.foundation

Responsive Installation

1 - Complete steps 1-3 of the General Installation.

2 - Run the install generator:

$ rails generate jquery:datatables:install responsive

This will add to the corresponding asset files

# app/assets/javascripts/application.js
//= require dataTables/jquery.dataTables
//= require dataTables/extras/dataTables.responsive

# app/assets/stylesheets/application.css
*= require dataTables/extras/dataTables.responsive

3 - Initialize your datatables using:

$('#example').DataTable({
  responsive: true
});

5 - Add responsive no-wrap class to html table,

<table class="display responsive no-wrap">
    <thead>
        <tr></tr>
    </thead>
    ...
</table>
  1. More information at: http://www.datatables.net/extensions/responsive/init

Plugins

Only a few plugins are currently available

  • api
    • fnReloadAjax
    • fnGetColumnData
    • fnFilterOnReturn
    • fnSetFilteringDelay
  • sorting
    • numbersHtml
  • typeDetection
    • numberHtml

These files can be found in the assets directory.

Extras

# Official extras are available:
[Plugin]     : [ExtraName]
AutoFill     : dataTables.autoFill
ColReorder   : dataTables.colReorder
ColVis       : dataTables.colVis
FixedColumns : dataTables.fixedColumns
FixedHeader  : dataTables.fixedHeader
KeyTable     : dataTables.keyTable
Scroller     : dataTables.scroller
TableTools   : dataTables.tableTools
Responsive   : dataTables.responsive

How to use Extras

1 - To add an extra into your application, add its JS file to application.js using the following pattern:

//= require dataTables/extras/[ExtraName]

2 - Additionally, you may need to add any associated CSS files. For instance the TableTools extra requires you to add the following line to your application.css file:

*= require dataTables/extras/dataTables.tableTools

Make sure to also add it's initialization as described on datatables extras' site.

Articles and Extras

RailsCast #340 DataTables Apr 11, 2012.

ajax-datatables-rails a wrapper around datatable's ajax methods that allow synchronization with server-side.

jquery-datatables-rails's People

Contributors

caffeineshock avatar colvint avatar crmaxx avatar esbanarango avatar genkilabs avatar irobayna avatar jahangiranwari avatar jcoleman avatar jessedoyle avatar jh125486 avatar joelbarker2011 avatar jojozepp avatar kobaltz avatar ktec avatar luismaia avatar mchapman17 avatar meidan1984 avatar mejackreed avatar peter-mac avatar poteto avatar rakvium avatar ricardodovalle avatar rubinsh avatar rweng avatar ryan2johnson9 avatar s-andringa avatar superscott avatar trkrameshkumar avatar wjgilmore avatar zencocoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-datatables-rails's Issues

FixedHeader seems to be out of date

TypeError: 'undefined' is not an object (evaluating 'jQuery.browser.msie'), FixedHeader line 268
is the error given when I try to add a fixed header.
I can't find the line in the DataTables/FixedHeader source, so I guess it's simply out of date.

Asset Pre-compilation Issue with datatables.

I installed this gem into my application but while deploying it, I get the following error:

dataTables/sort_both.png isn't precompiled
(in /home/deployer/apps/cuelinks/shared/bundle/ruby/1.9.1/gems/jquery-datatables-rails-1.10.0/vendor/assets/stylesheets/dataTables/jquery.dataTables.bootstrap.css.scss)

I use Twitter Bootstrap, if it matters and here's how my application.js and application.css looks like:

Application.js

//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require jquery-ui
//= require highcharts
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap

Application.css

*= require_self
*= require dataTables/jquery.dataTables.bootstrap
*= require_tree .

I am not sure what I am missing here....

add I18n plugin to this gem

Is possible add https://github.com/DataTables/Plugins/tree/master/i18n to this gem?

I am trying add languages to this gem but when I add a language I get a error and datatable is not working.

For example for the arabic language I have this files inside /javascripts/dataTables/media/language/ar.txt

This is my datatable config on my orders.js.coffee

$("#orders").dataTable(
    sDom: "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>"
    sPaginationType: "bootstrap"
    bProcessing: true
    sScrollX: "100%"
    bScrollCollapse: true
    bAutoWidth: false
    aaSorting: [[0, "desc"]]
    oLanguage:
      sUrl: "/assets/dataTables/media/language/ar.txt"
    aoColumns: [
      sWidth: "90px"
    ,
      sWidth: "120px"
    ,
      sWidth: "450px"
    ,
      sWidth: "40px"]
    bServerSide: true
    sAjaxSource: $('#orders').data('source')
    aoColumnDefs: [
      bSortable: false
      aTargets: ["unsortable"]
    ]).fnSetFilteringDelay()

What am I doing wrong?

I would like how can I add languages to datatable with this gem.

Thank you!

Reinitialize table twice on rails 4

I'm getting an error

DataTables warning (table id = 'users_list'): Cannot reinitialise DataTable.

To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy

Tried with those args, but no effect

Not working anymore

I have this

asa

my js file products.js

jQuery ->
$('#products').dataTable()

not working, it just to work last week

Bumping the gem version number

Hi,

I'm a novice when it comes to gem internals, but could you bump the version number so when running bundle install the gem is updated to reflect the latest changes (addition of the DataTables extras, notably). I even uninstalled the gem and ran bundle install anew but for some reason the latest extras aren't included. Any ideas why? Is it because the version number wasn't bumped when that commit was made?

Pagination type

I'm a bit wondering what I should write in the object used to initialize my datatable. For now I have this one:

{
  "paginationType": "bootstrap",
  "pagingType": "full_numbers",
  "sPaginationType": "bootstrap"
};

There are two different keys in the official documentation see http://datatables.net/forums/discussion/21184, but does the sPaginationType still used by this app?

By the way what I wrote doesn't work, if you have any idea why... Thanks!

Could not find jquery-datatables-rails-2.1.10.0.2 in any of the sources

Hi @ricardodovalle ,
Thanks for your reply.
Sorry, I could not understand by the statement 'Are you using rvm, rbenv or chruby?'
I have both rvm and rbenv in my system.

Did Rubymine set to the same ruby bin? - Yes

Did you install nodejs or therubyracer? - therubyracer

My Gemfile:

source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0.rc2'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'devise'

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS

# twitter bootstrap css & javascript toolkit
gem 'twitter-bootswatch-rails', '~> 3.2.0'

# twitter bootstrap helpers gem, e.g., alerts etc...
gem 'twitter-bootswatch-rails-helpers'

gem 'twitter-bootstrap-rails'

gem 'paper_trail', '~> 3.0.3'

gem "pundit"

# gem 'jquery-datatables-rails', '~> 2.1.10.0.2'

My application.js:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require turbolinks
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/2/jquery.dataTables.bootstrap
//= require_tree .

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

My application.css:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require_self
 *= require bootstrap_and_overrides
 *= require dataTables/jquery.dataTables
 *= require dataTables/bootstrap/2/jquery.dataTables.bootstrap
 */

Thanks again.
Regards,
Sushant

Feature Request: responds_to :datatable

Could you add functionality so that we can create a controller and allow it to respond to :data table, which would automatically process the params properly and return formatted (basically JSON with a twist) data to the datatable?

Would be a great way to expedite the development process, and keep code nice and clean :)

Just an idea.

Images in production

Sorting icons (assets/dataTables/sort_asc.png, desc.png etc.) not seen in production. Guessing that url needs to be replaced with asset-url for md5.

Rails 4.1 Compatibility

While upgrading to Rails 4.1, I got the following error:

ArgumentError at /
wrong number of arguments (2 for 1)
  (in /Users/jsantos/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/bundler/gems/jquery-datatables-rails-788a7b24caf8/app/assets/stylesheets/dataTables/jquery.dataTables.bootstrap.css.scss)

Any tips on this?

Thanks in advance

Gem not working properly....converting PUT(update) call to POST

I created a simple rails app:
:~ rails generate scaffold User name:string email:string
:~ rake db:migrate
and then edited _form.html.erb for using the DataTable Plugin:

screenshot from 2013-05-12 01 39 50

The form works completely well when a User is created. But, when i try update User's information it returns me a routing error:
No route matches [POST] "/users/1"

For Update the call should have been PUT but it is using POST here. It only happens when I use the Gem otherwise the Update is working fine.
Please look into the following matter.

More maintainers for this project

Hi Robin Wenglewski,

Could you please consider adding a "co-maintainer" ?
There are great pull requests features and perhaps you are busy.

Thanks.

Best regards,
Ricardo

Fixing Left most column for horizontal scrolling

I need to use the functionality provided by the following plugin:

http://datatables.net/forums/discussion/2815/fixedcolumns-new-plug-in-for-datatables-fix-columns-when-scrolling/p1

I am using your gem in my ruby on rails application and it works great. But it does not have support for this plugin yet. What is the best way to go about adding this plugin? I would like to do it in a reusable way, i.e., make it a part of your gem. However, I am quite new to datatables. I know a bit of Javascript/jQuery.

Kindly provide some direction.

Thanks.

Bharat

Scroller not working on Responsive Installation

Hello,

I am trying to implement the infinite scrollY.
I required the plugin in application.js
//= require dataTables/extras/Scroller

Here is my code:

tC = $('#keys')
tC.dataTable
    bJQueryUI: true
    bAutoWidth: false
    bStateSave: false
    sScrollY: "400px"
    sAjaxSource: $('#keys').data('source')
    bServerSide: true
    sDom: "frtiS"
    oScroller:
        loadingIndicator: true
    fnPreDrawCallback: ->
        responsiveHelper = new ResponsiveDatatablesHelper(tC, breakpointDefinition) unless        responsiveHelper
    fnRowCallback: (nRow, aData, iDisplayIndex, iDisplayIndexFull) ->
        responsiveHelper.createExpandIcon nRow
    fnDrawCallback: (oSettings) ->
        responsiveHelper.respond()`

When I add the sScrollY: "400px" the table start to brake, and the responsive side of it is not working at all(no column is hiding, and at resize the column header doesn't resize)

Thank you

Bundle install / gem install both install an older gem version.

When I run gem install jquery-datatables-rails, version 1.11.0 is installed by default even though version 1.11.1 is listed on github.

When I run gem install jquery-datatables-rails -v 1.11.1, it cannot find the gem.

Does the version number just need bumped to 1.11.1?

Gap with jquery.floatThead and margins

I am getting a gap between the top of the table header and the top of the viewport when using the floatThead plugin. See the screenshot below:

screenshot from 2014-01-24 00 43 27

I tracked the problem down to the presence of !important declarations in jquery.dataTables.bootstrap3.css.scss, line 44:

table.dataTable {
        clear: both;
        margin-top: 6px !important;
        margin-bottom: 6px !important;
        max-width: none !important;
}

This prevents the table from moving all the way to the top of the screen. Is there any reason why this is needed?

Missing a license.

I would like to use this gem to include DataTables in a Rails3+Backbone project. Unfortunately, I need to make sure that all my licensing is very clear.

Do you have a license in mind for this plugin? And would it be possible to add it to the repository?

Thank you.

Cannot set sSwfPath to have it to work

Hello
I'm developping an app on local.
I try to add TableTools to my dataTables. The TableTools buttons are well displayed on the page but they have no effect, I always have a routing error about swfPath.

What is the correct way to have TableTools working on local ?
Thanks for help

application.js

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap
//= require dataTables/extras/TableTools
//= require dataTables/extras/ZeroClipboard
//= require_tree .

users.js.coffee

jQuery ->

  #  Init the table
  $('#users-grid').dataTable
    bjQueryUI: true
    sDom: 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>'
    oTableTools:
      sSwfPath: "swf/copy_csv_xls_pdf.swf"
    sPaginationType: "bootstrap"
    bProcessing: true
    bServerSide: true
    sAjaxSource: $('#users-grid').data('source')

server log

Started GET "/backstage/swf/copy_csv_xls_pdf.swf" for 127.0.0.1 at 2013-02-26 11:48:11 +0100

ActionController::RoutingError (No route matches [GET]   "/backstage/swf/copy_csv_xls_pdf.swf"):
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  quiet_assets (1.0.1) lib/quiet_assets.rb:20:in `call_with_quiet_assets'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.5) lib/rack/runtime.rb:17:in `call'
 activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
 rack (1.4.5) lib/rack/lock.rb:15:in `call'
 actionpack (3.2.1) lib/action_dispatch/middleware/static.rb:53:in `call'
 railties (3.2.1) lib/rails/engine.rb:479:in `call'
 railties (3.2.1) lib/rails/application.rb:220:in `call'
 rack (1.4.5) lib/rack/content_length.rb:14:in `call'
 railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
 rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
 C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

  Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)

I tried different things with no results (copying the 'media" directory in my app/assets directory, or the swf directory in my assets/backstage/' directory etc...) no luck

Any help would be very appreciated

rowreorder on datatables

If I'm using the jquery-datatables-rails gem and I want to be able to drag and drop rows in my datatable, is that something I can do with this gem somehow? Does that functionality come with this gem?

Thank you!

DataTables 1.9.3

Thanks for the great gem.

DataTables version 1.9.3 has been available since August 8th. Currently this repository is on 1.9.2.

Use of vendor/ not sanctioned by docs, prevents images from being precompiled in 4rc2

Current engine guide recommends app/ :

2.1.2 app directory

Within the app/assets directory, there is the images, javascripts and stylesheets directories

And Edge engine guide recommends app/ or lib/ :

 the application will know to look up in the engine's app/assets and lib/assets directories for potential assets.

In my rails 4rc2 app, the datatables images are not precompiled. But in a similar gem that uses the recommended app/ instead of vendor/, the images are precompiled.
#24 may be related to this.

Update FixedColumns plugin

The current bundled version (2.0.4.dev) of FixedColumns.js throws $b.browser is undefined error for jQuery version 1.9+.

Could FixedColumns be updated to the latest version (2.5.0.dev) ?

It doesn't seem to install

I have added 'jquery-datatables-rails' to my gemfile and done a bundle install, but I don't see anything in the vendor/assets/javascript or stylesheets. I get errors when I try to use datatables because the files are not found. Could I be doing something wrong? I haven't seen anything where other people are having a similar problem.

oTableTools is not working fine

All is working fine except oTableTools extra.

I can not see the buttons xls, pdf, and csv as inside this example: http://datatables.net/release-datatables/extras/TableTools/bootstrap.html.

I have added to application.js:

//=require dataTables/extras/TableTools

and application.css.scss:

*= require dataTables/extras/TableTools
*= require dataTables/extras/TableTools_JUI

This is my datatable code:

$("#admin").dataTable({
  "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
  "sPaginationType": "bootstrap",
  "bProcessing"     : true,
  "sScrollX": "100%",
  "bScrollCollapse": true,
  "bAutoWidth": false,
  "aoColumns"       : [{"sType" : "html"}, null, null, null],
  "aaSorting"       : [[0, 'asc'], [1, 'asc']],
  "bServerSide"     : true,
  "sAjaxSource"     : "/admin/admins.json",
  "oTableTools": {
            "aButtons": [
                "copy",
                "print",
                {
                    "sExtends":    "collection",
                    "sButtonText": "Save",
                    "aButtons":    [ "csv", "xls", "pdf" ]
                }
            ]
        }
}).fnSetFilteringDelay();

I have added oTableTools like inside this example http://datatables.net/release-datatables/extras/TableTools/bootstrap.html to works with twitter bootstrap.

I can not see the buttons to export to csv, xls, and pdf format...etc

What am I doing wrong? Where is the problem?

Thank you very much

Rails 4.0.2 and Foundation 5.0.2

All of the instructions work fine but when I first load the page that contains the datatable, it just shows a normal table. If I hit F5 after and reload the page, the datatable then loads properly. However, the pagination at the bottom shows text instead of images.

I use a simple method helper to load the datatable in the head. However, I also cannot use SPaginationType foundation and have to use full numbers instead. When using foundation pagination type the entire table disappears.

def jqtable(element_id)
    content_for(:head) {
      "<script type=\"text/javascript\" charset=\"utf-8\">
      $(document).ready(function() {
        $('##{element_id}').dataTable({
          \"sPaginationType\": \"foundation\", <== this by itself does nothing
          \"sPaginationType\": \"full_numbers\"  <== using this 
        });
      });
    </script>".html_safe
    }
end

Application.js contains

//= require jquery
//= require jquery_ujs
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.foundation
//= require foundation
//= require turbolinks


$(function(){ $(document).foundation(); });

Application.css contains

 *= require_self
 *= require foundation_and_overrides
 *= require coftheme
 *= require site
 *= require dataTables/jquery.dataTables.foundation
 *= require home

index with the user table shows:

<% jqtable('user') %>

<div class="row">
  <div class="large-12 columns">
    <div class="userdiv centered">
      <h1>Current Users</h1>

      <table cellpadding="0" cellspacing="0" border="0" width="100%" class="display" id="user">
        <thead>
          <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Email</th>
            <th># of Signins</th>
            <th>Provider</th>
            <th>UID</th>
            <th>Last Signed In</th>
            <th>IP Address</th>
          </tr>
        </thead>
        <tbody>
          <% @users.each do |user| %>
          <tr class="gradeX">
            <td class="center"><%= user.id %></td>
            <td class="center"><%= user.name %></td>
            <td class="center"><%= user.email %></td>
            <td class="center"><%= user.sign_in_count %></td>
            <td class="center"><%= user.provider %></td>
            <td class="center"><%= user.uid %></td>
            <td class="center"><%= user.last_sign_in_at %></td>
            <td class="center"><%= user.last_sign_in_ip %></td>
          </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </div>
</div>

The head tag contains:

<!-- Head Section -->
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title><%= content_for?(:title) ? yield(:title) : @site_title %></title>
  <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->
  <%= stylesheet_link_tag  "application" %>
  <%= javascript_include_tag "vendor/modernizr" %>
  <%= javascript_include_tag "jquery" %>
  <%= yield(:head) %>
  <%= csrf_meta_tag %>
</head>
<!-- /end Head -->

I have tested with jquery in the head and out of the head before the body. Both do not work. Foundation is then loaded at the bottom before the body per the new revision in 5.0.x.

DataTables v1.10.0

Hi!

does the gem include the recently released DataTables v.1.10.0 ?
thanks.

non-standard image-url in css

I was curious why in the css image-url is used for all the background properties instead of just the standard url. Sass complains about invalid CSS

table.dataTable thead .sorting { background: image-url('dataTables/sort_both.png') no-repeat center right; }

throws the error:

Invalid CSS after "...ables/sort_both": expected ")", was ".png) no-repeat..."

using url, it compiles fine.

Cannot reinitialise DataTable, when using Twitter Bootstrap

I'm getting the below error message when using twitter bootstrap:

DataTables warning (table id = 'products'): Cannot reinitialise DataTable.

To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy

FixedColumns Plugin not working :(

I had opened issue number 8 awhile ago and you were kind enough to include the FixedColumns plugin at my request. This morning, I finally got the chance to test it in my application. Something is wrong since it is not working, but I cannot see any errors in the Firebug console, so apparently it has been included correctly.

Here is what I have done based on the instructions provided:

  1. I included the FixedColumns plugin in my app/assets/javascripts/application.js file as shown below:

//= require jquery
//= require jquery_ujs
//= require jquery.ui.tabs
//= require dataTables/jquery.dataTables
//= require dataTables/extras/FixedColumns
//= require jquery.formalize
//= require highcharts
...

Here is the FixedColumns plugin related jQuery code:

var oTable = $("#sys_outs,#volumes").dataTable({
  "bFilter": false,
  "bSort": false,
  "bPaginate": false,
  "bJQueryUI": true,
  "bScrollInfinite": true,
  "bScrollCollapse": true,
  "sScrollY": "400px",
  "sScrollX": "100%",
  "sScrollXInner":"150%",
  "iDisplayLength": 20,
  "aoColumnDefs": [
    { "sWidth": "20%", "aTargets": [ -1 ] }
  ],
  "oLanguage": {
      "sInfo": "Number of rows = _TOTAL_"
  } 
});
new FixedColumns(oTable);

The FixedColumns plugin does not seem to have any effect whatsoever, i.e., the left-most column is not frozen and keeps scrolling. No errors whatsoever in the Firebug console.

Please advise on how to debug this issue?

Thanks.

Bharat

using bootstrap3, filter input field does not have class "form-control"

$('#table').dataTable
sDom: "<'row'<'col-md-6'><'col-md-6'>r>t<'row'<'col-md-6'f><'col-md-6 pull-right'p>>"
sPaginationType: "bootstrap"
bLengthChange: false
bInfo: false
aaSorting: [[ 1, "asc" ]]
aoColumns: [
{ sWidth: "05%", bSortable: false },
{ sWidth: "15%" },
{ sWidth: "15%" },
{ sWidth: "10%" },
{ sWidth: "15%" },
{ sWidth: "10%", sClass: "center" },
{ sWidth: "10%" },
{ sWidth: "10%" },
{ sWidth: "10%" }
]

Generates the following filter input field:

but it should have class "form-control", right?

update extras

Datatables core was updated [here], before releasing a new gem we need to update the extras.

Column property "mData" is not accepted (but should be)

The commit 12c494e says that the JS has been updated to DataTables v1.9.2, and the official documentation for mData says that

prior to DataTables 1.9.2 mData was called mDataProp

(my emphasis). However, the JS in this gem currently doesn't accept the new property name mData, just the old one (mDataProp) โ€“ took me hours to figure it out...

sass dependency not in gemfile

I didn't get a warning (or dependency installation) from bundler about having sass disabled in rails. When including/compiling the datatables css bootstrap file I got a sass missing error. Easy to fix, but should probably be in as a gem dependency?

Or if sass isn't being used in the markup (it looks like plain css to me, but I'm not very familiar with the difference) the files could be renamed to .css ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.