How to get the value entered in the search box What is a way to get value in the search box in the data table in Datatables?
If a search is performed then you want to check the value [datatels 1.10 .x ]:
var table = $ ('# example'). Datatelle (); $ ('# Example') ('Search.dt', function () {var value = $ ('.dattoo_filter input'). Val (); console.log (value); // <- the value});
If you want to check the value before the search and are able to cancel the search, you will need to unbundle the default searchbox event and create your own, such as - Only when the user has entered more than 3 characters:
$ ('dataTables_filter input'). Unbind (). Keyup (function () {var value = $ (this) .val (); if (Value.length> 3) {table.search (value) .draw ();}});
Demo ->
To completely reset the search / filter, such as the user has deleted the search term: < / P>
if (value.length == 0) table.search (''). Draw ();
Comments
Post a Comment