I have a tab panel on my html where I am rendering a table.
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
<div role="tabpanel" class="tab-pane" id="manualProcess">
<div class="container" id="annotationTable" class="display nowrap" cellspacing="0" width="100%">
</div>
</div>
I am rendering the table through a php script from mysql. Function getManual() gets triggered on clicking the tab panel.
function getManual() {
var folder = $('#workingDir').val();
$.post('manualAnnotation.php', {'folder': folder}, function(data) {
$('#annotationTable').html(data).show();
})
}
And my php that renders the table is as follows:
$result = mysqli_query($connect,$sql)or die(mysqli_error());
echo "<div class='col-md-5'><table class='dataTable' cellspacing='0' id='manTab'>";
echo "<thead><tr><th>Select</th><th>Image</th><th>Location</th><th>Brand</th><th>Run</th></tr></thead>";
while($row = mysqli_fetch_array($result)) {
$ID = $row['ID'];
$Image = $row['Image'];
$Location = $row['Location'];
$Brand = $row['Brand'];
echo "<tbody><form><tr>
<td><div class='radio' style='padding:0px;margin:0px'><label><input type='radio' value='$ID' id='manualTab' name='manualTab'></label></div></td>
<td>".$Image."</td>
<td>".$Location."</td>
<td>".$Brand."</td>
<td><a href='#' onclick='runManual()'>RUN</a></td>
</tr></tbody></form>";
}
echo "</table></div>";
mysqli_close($connect);
I am trying to enable the jQuery dataTable on the table id "manTab". On my index page, i have added this code:
$(document).ready(function() {
$('#manTab').DataTable({
});
});
While this renders the table the functionalities of datatable such as search, sort or pagination is not enabled.