Why am I getting a TypeError within my datatable?

Why am I getting a TypeError within my datatable?

BradleyO07BradleyO07 Posts: 11Questions: 8Answers: 0

I am currently building a datatable and I keep getting this error code within my table:

Uncaught TypeError: Cannot read properties of undefined (reading 'sWidth')

Below is my code:

var mainDT;

/**
 * Generates the Tables
 */
function getTable() {
  mainDT = $('#siloTable').DataTable({
      display: 'envelope',
      ajax: {
        'type': 'POST',
        'url': '../ajax/silo/SiloTable.ajax.php',
        'data': {
          'getTable': 1,
        }
      },
      table: ('#siloTable'),
      scrollX: true,
      order:[[ 0, "desc" ]],
      iDisplayLength: 25,
      fixedColumns:   true,
      dom:
        "<'row'<'col-8 col-md-4 col-lg-3'l><'col-md-6 col-lg-8 d-none d-md-block text-center'><'col-2 col-md-2 col-lg-1 button-right'B>>" +
        "<'row'<'col-sm-12'tr>>" +
        "<'row'<'col-sm-5'i><'col-sm-7'p>>",
      columns:[
        { data: "sample_datetime" },
        { data: "recycle" },
        { data: "preset" },
        { data: "weight" },
        { data: "preact" },
        { data: "dribble" },
        { data: "concet" },
      ],
      buttons: ['csv'],
  });
}

$(document).ready(function(){
  getTable();
});

Can anyone help me on why I am getting this error?

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.