Created
August 10, 2017 18:16
-
-
Save blueridgemountains1/c3cc02e5fc99ecf46fb39adbfb50c02e to your computer and use it in GitHub Desktop.
DataTables with Search and Defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $dt = $('.dataTable') | |
.DataTable({ | |
"lengthChange": true, | |
"pageLength": 21, | |
"paging": true, | |
"ordering": true, | |
"info": false, | |
"searching": true, | |
"stateSave": false, | |
"jQueryUI": false, | |
"lengthChange": false, | |
"columnDefs": [{ | |
"targets": "no-sort", | |
"orderable": false | |
}], | |
"language": { | |
"paginate": { | |
"previous": "<span class='glyphicon glyphicon-bold-arrow'></span>", | |
"next": "<span class='glyphicon glyphicon-bold-arrow'></span>" | |
}, | |
"emptyTable": "No search results." | |
}, | |
"initComplete": function(settings, json) { | |
$('.dataTables_paginate').each(function(index, value) { | |
if ($(this).find(' > span a.paginate_button').length < 2) { | |
$(this).hide(); | |
} | |
}); | |
$(this).show(); | |
} | |
}); | |
$('#record-search .form-control').on( 'keyup', function () { | |
console.log('text!'); | |
$dt.search( this.value ).draw(); | |
} ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment