Integer search in select based filter
Integer search in select based filter
I have a column containing few integer values, namely 50, 100, 150, 200, 250, 300
I have applied a select filter on that column using following code:
var select = $('<select><option value=""></option></select>')
.appendTo($(this).empty())
.on('change', function() {
dt.column(i).search(parseInt($(this).val()), true, false).draw();
});
dt.column(i).data().unique().sort().each(function(d, j) {
select.append('<option value="' + d + '">' + d + '</option>');
});
But using this, if I select 50 from select filter then it shows me 150 and 250 values as well along with 50. As 150 and 250 also contain 50 in them, if you consider them as string. What I need is to ask datatables to consider values as integer and then search.
I have looked into API but found that search() function takes strong argument, I tried passing after doing parseInt() as well, but no use. Is there any other function or any way to do a filter based on integer.
Answers
You can try my yadcf plugin http://yadcf-showcase.appspot.com/ it has simple select / range of numbers / range of number with slider widget / and 6 others type :)
In yadcf the following will be enough
Otherwise try googling for datatables exact filter match...