javascript - Jquery Datatable search -
i've created datatable using jquery datatable.
$('#mytable').datatable({ "pagingtype": "simple_numbers", "blengthchange": false, "idisplaylength": 10, "aasorting": [[0, 'asc']], "processing": true, "serverside": true, "ajax": $('#mytable').data('source'), "aocolumndefs": [ {'bsortable': false, 'atargets': [3, 4]} ] });
but how can search on data displayed on table?
var datatable = $('#mytable').datatable(); $('#yourinputfieldid').on('input keyup paste', function () { datatable.fnfilter(this.value); });
// prevent submit on enter need prevent default behaviour of enter key on keydown event
$('#yourinputfieldid').keydown(function (event) { if (event.keycode === 13) { event.preventdefault(); return false; } });
Comments
Post a Comment