Data tables not Loading

Data tables not Loading

runtmanruntman Posts: 3Questions: 1Answers: 0

Hello, I am trying to use datatables but I am seeing the below error in my console.

I am trying to use datatables to make my last 3 columns formatted, I have changed the way I print the headers from TDs, to TH this causes a issue with the formatting of the table but I can fix that if I look into it, but the code it's self just seems to error with this error,

Uncaught TypeError: Cannot read property 'ext' of undefined

Below is the code I am using and also a photo of the problem, any help with be appreciated.

The code I am using the below code:
Below is in the HTML header

 <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.3/css/jquery.dataTables.css">

This is in the HTML header also, open and closed with php tags.

 // DataTables JS for user statistics
 print '<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.3/js/jquery.dataTables.js"></script>';
 print '<script type="text/javascript">
       jQuery(document).ready(function() {
                jQuery.fn.dataTable.ext.errMode = "throw";
                jQuery(\'#userstatistics\').DataTable({
                "columns": [
                        { "orderable": false },
                        null,
                        null,
                        null
                ]
                });
        });
</script>';

The way I print the table is below:

 print"<table id='userstatistics' class='table table-striped'>";
    echo "<thead><tr><th>   </th><th><h4> Agent </h4></th><th><h4> Tickets Open/New </h4></th><th><h4> Tickets Closed </h4></th></tr></thead>";
    print "<tbody>";
    while($row = mysqli_fetch_array($result)) {
        $open_tickets = $row['tickets_open'];
        echo "<tr><td><img height='40' width='40' src='{$row['user_photo']}'></td><td>" .$row['user_firstname']. " " .$row['user_surname'].
        "</td><td>" .$row['tickets_open']. "  ";
            if ($open_tickets < $kpi['kpi_tickets_green']) {
                echo "<i class=\"fa fa-thumbs-o-up\"></i>";
            } elseif ($open_tickets >= $kpi['kpi_tickets_green'] && $open_tickets < $kpi['kpi_tickets_amber']) {
                echo "<i class=\"fa fa-thumbs-o-down\"></i>";
           } else {
               echo "<i class=\"fa fa-exclamation-triangle\"></i>";
           }
        echo "</td><td>" .$row['tickets_closed']. "</td></tr>";
    }
    print "</tbody></table>";

http://imgur.com/YDoZI7i

This is the outcome, if you need any more information feel free to ask.

Answers

  • runtmanruntman Posts: 3Questions: 1Answers: 0

    Hmmm, even using this base code, it makes no difference

    $(document).ready( function () {
    $('#table_id').DataTable();
    } );

  • anjibmananjibman Posts: 115Questions: 10Answers: 0

    With basic code its also same error?

  • runtmanruntman Posts: 3Questions: 1Answers: 0

    Aha, the basic code was failing due to a failed GET, this is now resolved. Sorry for the noob quesiton.

This discussion has been closed.