buttons plugin intermittently just does not appear

buttons plugin intermittently just does not appear

guidoriceguidorice Posts: 8Questions: 4Answers: 1

I have an issue, with the buttons plugin sometimes not rendering, and there are no javascript errors or warnings. I am create datatables with options like this:

  dom: 'lfrtipB',
  buttons : ['colvis', 'copyHtml5', 'csvHtml5', 'excelHtml5'],
  colReorder : true,
  data: ...,
  columns: ...

Sometimes the buttons appear, and sometimes they do not. If I reload the page, they appear. Here is the contents of my downloaded .zip for datatables:

Buttons-1.2.4/
ColReorder-1.3.2/
DataTables-1.10.13/
JSZip-2.5.0/

I am loading datatables like this

this.table = $(this.tableElement).DataTable(opts);

This is a dynamic single page app, made with aurelia, and sometimes I need to re-draw a table in a custom element, which I am doing some cleanup like this:

  if(this.table) {
      this.table.destroy();
      $(this.tableElement).empty();
    }

^^ does the above also cleanup the buttons plugin?

Is there a way to get the buttons plugin to be more verbose if it fails to load? Any other suggestions for solving this? I am kind of stuck here.

Answers

  • guidoriceguidorice Posts: 8Questions: 4Answers: 1

    I was able to resolve the behavior by doing this instead of using the buttons options property:

      new $.fn.dataTable.Buttons(
          this.table,
          this.conf.datatablesNet._buttons
        );
      this.table.buttons().container()
          .appendTo(this.table.table().container());
    
This discussion has been closed.