Last active
April 24, 2025 17:10
-
-
Save surferxo3/d1b4b21dffc4feebea926f62819ac5e5 to your computer and use it in GitHub Desktop.
Perform global search on DataTables either via enter keypress or button click
This file contains hidden or 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
// reset search on input clear / special 'x' click | |
$('.dataTables_filter input') | |
.unbind() | |
.bind('keyup input', function (e) { // works both for keyboard input and for special 'x' click mouse input | |
var searchTerm = $(this).val().trim(); | |
if (searchTerm === '' || e.keyCode === 13) { | |
prodFilesTable.search(searchTerm).draw(); | |
} | |
}); | |
// perform search on button click | |
$('.search').click(function () { | |
prodFilesTable.search($('.dataTables_filter input').val()).draw(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment