add export button to csv in a ROR application

add export button to csv in a ROR application

hasileinhasilein Posts: 1Questions: 0Answers: 0
edited May 2020 in Free community support

Hello,

i try to add an export button to the datatable like the follow way in the application.js of an ROR Application but it does not show the button see the code below.
Can anybody help me here? :# :#

document.addEventListener("turbolinks:load", () => {
  $('.toast').toast({ delay: 5000})
  $('.toast').toast('show');

  $("table[role='datatable']").each(function(){
    $(this).DataTable({
      processing: true,
      serverSide: true,
      responsive: true,
      pageLength: 10,
      ajax: $(this).data('url'),
      dom: 'Bfrtip',
        buttons: [
            {
                extend: 'excelHtml5',
                title: 'Data export'
            },
            {
                extend: 'pdfHtml5',
                title: 'Data export'
            }
        ]    
    },);
  });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Replies

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    That looks OK. Are you including the necessary JS files?

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.