jQuery Datatable Filter Customisation
I 开发者_如何学Gohave a typical requirement when searching data dynamically in jQuery datatable.
Is it possible to bind the search field with a button? What I mean is I don't want to redraw the table based on each character input. I wish to first enter the data in the field and then search the table by clicking the button.
If anyone of you has done something similar I'd be much obliged if you could assist.
Thanks a lot for any kind of help.
I know its been a while since you posted but nogody has answered so I thought I would add something in case other people are looking for the answer. The code below will activate a search when an anchor is clicked (can be styled as a button or you can use a button as well). It finds the search text box (in this case a custom text box that I created), gets the value, finds the table, provides the filter value to the table and then redraws the table.
$('a#searchfilter').click(function (e) {
e.preventDefault();
var ele = $(this).prev();
var term = ele[0].value;
var oTable = $('#primarytable').dataTable();
oTable.fnFilter(term, null, false, true, false);
oTable.fnDraw();
});
精彩评论