Actually I am new to jQuery datatables plugin.
I have attached the plugin to my tables using this method using this code.
$(document).ready(function() $('#table_id').dataTable({ }); });
Now What I want is datatables provides a text box in which we can enter our filter string and results will be getting filtered.
So I want to use my existing designed textbox for that purpose I don't want to add a new textbox in the UI. So I gone through this link
http://datatables.net/examples/basic_init/dom.html
But I am not understanding. Is it possible to use the existing textbox. Please advice
See I was having situation like this before implementing this datatables
Now when I apply this datatables plugin A new text box gets added for search I don't want to a new text box I want my existing textbox to implement search functionality.
DataTable({ "sDom": 'Lfrtlip' }); From this you can set to bottom. Show activity on this post.
sDom. Show details. This initialisation variable allows you to specify exactly where in the DOM you want DataTables to inject the various controls it adds to the page (for example you might want the pagination controls at the top of the table).
The lengthChange option is used to specify whether the dropdown to change the number of rows per page is displayed or not. This dropdown is shown only when paging of the DataTable is enabled, as disabling it automatically removes the dropdown.
Description. This method provides the ability to check if a table node is already a DataTable or not. This can be useful to ensure that you don't re-initialise a table that is already a DataTable.
This is very simple. First you must hide the default search box :
.dataTables_filter { display: none; }
Example of your own designed search box, placed somewhere in the HTML :
<input type="text" id="searchbox">
script to search / filter when typing in the search box
$("#searchbox").keyup(function() { dataTable.fnFilter(this.value); });
working demo -> http://jsfiddle.net/TbrtF/
If you are using DataTables 1.10 the JS should look like:
$("#searchbox").on("keyup search input paste cut", function() { dataTable.search(this.value).draw(); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With