Get a nice datatable with records but features don't work- Record limit, sorting, search
Get a nice datatable with records but features don't work- Record limit, sorting, search
CJWatson
Posts: 3Questions: 1Answers: 0
<head>
<!-- Nav bar -->
<link href="css/navbar-fixed-top.css" rel="stylesheet" type="text/css" >
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Datatables -->
<link rel="stylesheet" type="text/css" href="dataTables.css"/>
<link rel="stylesheet" type="text/css" href="DataTables-1.10.12/css/jquery.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="Buttons-1.2.1/css/buttons.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="FixedHeader-3.1.2/css/fixedHeader.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="Responsive-2.1.0/css/responsive.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="Select-1.2.0/css/select.dataTables.css"/>
</head>
<body>
<script type="text/javascript" src="jQuery-2.2.3/jquery-2.2.3.js"></script>
<script>window.jQuery || document.write('<script src="jQuery-2.2.3/jquery-2.2.3.min.js"><\/script>')</script>
<!-- Dropdown -->
<script type="text/javascript" src="js/dropdown.js"></script>
<script type="text/javascript" src="js/bootstrap-Dropdown.js"></script>
<script>
$(document).ready(function() {
$(".dropdown-toggle").dropdown('toggle');
});
</script>
<!-- DataTables -->
<script type="text/javascript" src="datatables.js"></script>
<!-- <script type="text/javascript" src="datatables.min.js"></script> -->
<!-- <script type="text/javascript" src="js/datatables.bootstrap.min.js"></script> -->
<!-- Data Tables Extras -->
<!--
<script type="text/javascript" src="pdfmake-0.1.18/build/pdfmake.js"></script>
<script type="text/javascript" src="pdfmake-0.1.18/build/vfs_fonts.js"></script>
<script type="text/javascript" src="DataTables-1.10.12/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="Buttons-1.2.1/js/dataTables.buttons.js"></script>
<script type="text/javascript" src="Buttons-1.2.1/js/buttons.colVis.js"></script>
<script type="text/javascript" src="Buttons-1.2.1/js/buttons.html5.js"></script>
<script type="text/javascript" src="Buttons-1.2.1/js/buttons.print.js"></script>
<script type="text/javascript" src="FixedHeader-3.1.2/js/dataTables.fixedHeader.js"></script>
<script type="text/javascript" src="Responsive-2.1.0/js/dataTables.responsive.js"></script>
<script type="text/javascript" src="Select-1.2.0/js/dataTables.select.js"></script>
-->
<!-- Datatables -->
<script>
$(document).ready(function() {
var table = $('#example').DataTable();
});
</script>
<script>
$('#example').dataTable( {
"lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
} );
</script>
<script>
$('#example').dataTable( {
"pageLength": 10
} );
</script>
<script>
$('#example').dataTable( {
"ordering": false
} );
</script>
Below here is the connect to mysql with a search that puts the records in a table.
Get a nice datatables list but sorting, record limiting and search does not work
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan
Hi CJWatson,
As per suggestions..
1. Datatables live is offline - so I couldn't post a test page
2. Put java script at bottom of body - No difference. Still get Nice layout but search, record limit and sort still don't work.
3. Simplified code with just basic initialization
The live site is running just now. Or you could use JSFiddle, JSBin or CodePen.
The one thing that stands out for me in the code above is that your
tbody
is in thewhile
loop. So you have atbody
for every row. That isn't something DataTables currently supports - just a singletbody
. Move it outside thewhile
.Allan
Thanks All for your comments.! Allan the tbody tag was the issue. Moved it outside the while statement and all is well.
Mahalo for looking at the code figuring it out.
CJ Watson