Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35285

Fill search box on button click

$
0
0

Maybe I'm making this harder than it is but how do you fill the search box with a term on a button click?

Right now I use a pretty ugly 'hack' to get it to work:

$(document).ready( function () {   
    var table = $('#example').DataTable();
     $('#btnSearch').click(function (){
           table.destroy();
           var tbl = $('#example').DataTable({
               "oSearch": {"sSearch": "Initial search"}
           });
       });
} );

Basically on my button click I destroy the current table and initialize a new one with an initial search term. There has to be an easier way though.


Viewing all articles
Browse latest Browse all 35285

Trending Articles