0

Table is loaded with data but after some miliseconds datatable cleared the loaded data and a row comes with message "No matching records found" enter image description here

HTML Code

<table id="table">
<thead>
    <tr>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
        <th><span class="table_header">Heading</span></th>
    </tr>
</thead>
<tbody>
    <?php get_data_from_db(); ?>
</tbody>

Where get_data_from_db(); is afunction which is returning the rows in form of below.

$record = <<<DELIMETER 
<tr>   // Repeated with data    </tr>
DELIMETER;
echo $record;

Here is the Javascript Code

$('#table').DataTable();

Link DataTable files

<!-- Datatable css -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.bootstrap4.min.css">
<!-- Datatable JS-->
<script src="http://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
<script src="http://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
<script src="http://cdn.datatables.net/buttons/1.6.2/js/dataTables.buttons.min.js"></script>
<script src="http://cdn.datatables.net/buttons/1.6.2/js/buttons.bootstrap4.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="http://cdn.datatables.net/buttons/1.6.2/js/buttons.html5.min.js"></script>
3
  • 1
    I am facing the same issue Commented Oct 8, 2020 at 18:29
  • 1
    Can't tell from what I see. But please make sure, the html is generated properly, second see if $.DataTable() tries to initiate before the dom ready state. It needs to have the html rendered in order to work properly. Commented Oct 8, 2020 at 18:36
  • I verified the genrated html more the three but still getting same and the javascript code is in $(document).ready(function(){}); Commented Oct 8, 2020 at 18:45

1 Answer 1

1

Please verify that your tags have properly assigned with a unique ID not only the table but all of tags like input, label, select etc

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it works for me I gave all of my tags unique IDs

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.