Added filtering to a jQuery DataTables plugin, and it is not working very well.
I want to have two links that will search for records on specific search words. To figure out how to do that I first tried to use this example. It uses an input field to search for values in the table. It generates this error:
Uncaught TypeError: table.search(...).draw is not a function
My code:
$(document).ready(function() {
$('#store-list').dataTable({
"sPaginationType": "full_numbers"
});
var table = $('#store-list').DataTable();
$('#myFilter').on( 'keyup', function () {
table
.search( this.value )
.draw();
} );
});
I have tried different things to make this work:
Swapped
.DataTable()
with.dataTable().api()
and.dataTable()
Tried
( this.val() )
and( $('#myFilter').val() )
(link)Tried
table.search( this.value ).draw;
(without()
)In desperation I tried without
search
and then withoutdraw
Can someone please help me find the error?