2014-08-22 15:08:54 +02:00
|
|
|
$(function () {
|
2018-06-18 10:04:17 -07:00
|
|
|
$.extend(true, $.fn.dataTable.defaults, {
|
|
|
|
|
"stateSave": true,
|
|
|
|
|
"autoWidth": false,
|
|
|
|
|
"pagingType": "full_numbers",
|
2018-06-20 15:17:27 -07:00
|
|
|
"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
|
2017-08-08 12:41:37 +03:00
|
|
|
});
|
2018-06-18 10:04:17 -07:00
|
|
|
|
|
|
|
|
$('.datatable:not([data-source])').DataTable();
|
|
|
|
|
|
2018-06-20 12:41:05 -07:00
|
|
|
$('.datatable').on('init.dt', function (e, settings, json) {
|
|
|
|
|
var datatableApi = $(this).dataTable().api();
|
|
|
|
|
// Thanks to cale_b: https://stackoverflow.com/u/870729
|
|
|
|
|
// Stack Overflow question: https://stackoverflow.com/q/5548893
|
|
|
|
|
// Stack Overflow answer: https://stackoverflow.com/a/23897722
|
|
|
|
|
// Grab the datatables input box and alter how it is bound to events
|
|
|
|
|
$(".dataTables_filter input")
|
|
|
|
|
.unbind() // Unbind previous default bindings
|
|
|
|
|
.bind("input", function(e) { // Bind our desired behavior
|
|
|
|
|
// If the length is 3 or more characters, or the user pressed ENTER, search
|
|
|
|
|
if(this.value.length >= 3 || e.keyCode == 13) {
|
|
|
|
|
// Call the API search function
|
|
|
|
|
datatableApi.search(this.value).draw();
|
|
|
|
|
}
|
|
|
|
|
// Ensure we clear the search if they backspace far enough
|
|
|
|
|
if(this.value == "") {
|
|
|
|
|
datatableApi.search("").draw();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-11-14 11:58:36 +01:00
|
|
|
});
|