1

I added this gem

gem 'jquery-datatables-rails', github: "rweng/jquery-datatables-rails", branch: "master"

and then updated my application.js and application.css with

//= require dataTables/jquery.dataTables
 *= require dataTables/jquery.dataTables

Now in my products.js.coffee file

table = jQuery ->
    $("#products").DataTable()

new jQuery.fn.dataTable.Buttons( table, {
    buttons: [
        'copy', 'excel', 'pdf'
    ]
})

table.buttons().container()
  .appendTo( $('#exportButtons', table.table().container() ) )

and I'm getting the error

TypeError: c is undefined

I'm stuck and don't have any idea where is the problem. Is this datatable gem does not support the latest release of datatables export buttons

2
  • Have you considered trying the gem from Rails Assets instead? I always prefer to get UI related libraries from there as they do not rely on other maintainers to keep up with the library updates. Commented Jan 8, 2016 at 8:36
  • I prefer not using any gem now, and just files from datatables as it is.Everything is working fine with it. Commented Jan 8, 2016 at 11:11

1 Answer 1

1

You might want to explicitly download and include JS & CSS files for button.

application.js looks as follows-

//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
//= require ./DataTables/buttons/dataTables.buttons.min
//= require ./DataTables/buttons/buttons.bootstrap.min
//= require ./DataTables/buttons/buttons.html5.min

application.scss looks as below-

*= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
*= require ./DataTableStyles/buttons/buttons.dataTables.min
*= require ./DataTableStyles/buttons/buttons.bootstrap.min

I have downloaded buttons extension for tables explicitly and added to the asset pipeline in folder DataTables & DatableStyles.

Also don't forget to include html5 version of buttons-

buttons: [
    'copyHtml5', 'excelHtml5', 'pdfHtml5'
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.