Hide DataTables ‘Search and Pagination’
If you’re using DataTables, a jQuery plugin for enhancing HTML tables, and you want to remove pagination, search, ordering and other things you can do so by configuring the DataTables options appropriately. Pagination in DataTables is controlled by the “paging” option.
How to disable Datatable paging, search & other options
Here’s an example of how you can initialize DataTables and disable pagination after initialization:
disable datatables paging, search & others after initialization:
// set paging parameter in false on object configuration
$(document).ready(function() {
$('#dataTableId').DataTable( {
"searching": false,
"paging": false,
"ordering": false,
"info": false,
"lengthChange":false
} );
} );
Replace dataTableId with the actual ID of your table. Setting “paging”: false will disable pagination for the DataTable.
In the same way, setting “searching”: false will hide the search option & so on.
Make sure you include the required DataTables JavaScript and CSS files in your HTML document. You can either download them and host them locally or include them from a CDN. Here’s an example using CDN:
example – setting pagination false:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your Page</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>
<script>
$(document).ready(function() {
$('#dataTableId').DataTable({
"paging": false
});
});
</script>
</head>
<body>
<!-- Your table goes here with the corresponding ID -->
<table id="dataTableId">
<!-- table content -->
</table>
</body>
</html>
Make sure to check the DataTables documentation for the version you are using, as some options may vary slightly between versions: https://datatables.net/manual/