15
rated 0 times
[
20]
[
5]
/ answers: 1 / hits: 18224
/ 10 Years ago, wed, january 28, 2015, 12:00:00
I am using jquery datatables to make my table searchable. I have a dropdown that filters a gender column:
$(#genderDrop).on(change, function(e) {
var gender = $(this).val();
formTable.column(2).search(gender).draw();
});
this works fine, but now I want to be able to remove the filter when the user selects all from the dropdown. Here is my attempt:
$(#genderDrop).on(change, function(e) {
var gender = $(this).val();
if (gender != all) {
formTable.column(2).search(gender).draw();
} else {
formTable.column(2).search().draw();
}
});
Instead of removing the filter this just searches for an empty string, but I can't work out how to change this so it removes the filter. I also tried:
formTable.column(2).search(*).draw();
and
formTable.column(2).search().draw();
but without any success.
More From » jquery