HI.
i would like to use a filter for each column with checkbox.
For just one column it's ok but i don't know how use the script to add the same filter for others.
Thanks.
Not quite sure I understand I'm afraid. You are already using fnFilter to limit the column filter to a single column (the first, `0` , column in your example). Would you not just do the same again with the other column indexes?
Hi allan.
Yes i just want to do the same again with each columns indexes.
$('#example').dataTable().fnFilter(filter, 0, regexFilter, smartFilter);
$('#example').dataTable().fnFilter(filter, 1, regexFilter, smartFilter);
$('#example').dataTable().fnFilter(filter, 2, regexFilter, smartFilter);
.....
it may be simple, but I'm not familiar with the javascript language. I tested things without success...
Better yet would be to put it in a function and call it, passing in the column index you want to filter on, so you don't have large amounts of duplicate code.
Replies
Allan
Yes i just want to do the same again with each columns indexes.
$('#example').dataTable().fnFilter(filter, 0, regexFilter, smartFilter);
$('#example').dataTable().fnFilter(filter, 1, regexFilter, smartFilter);
$('#example').dataTable().fnFilter(filter, 2, regexFilter, smartFilter);
.....
it may be simple, but I'm not familiar with the javascript language. I tested things without success...
Thanks.
Maybe you're understand with this ie (it not work...):
http://fiddle.jshell.net/haTd3/5/
[code]
$(':checkbox[name="rendering_filter"]').click(function() {
var filter = '',
regexFilter = true,
smartFilter = false;
filter = $('[name="' + this.name + '"]:checked').map(function () {
return this.value;
}).toArray().join('|');
$('#example').dataTable().fnFilter(filter, 0, regexFilter, smartFilter);
});
[/code]
Why not duplicate it for the other columns?
Better yet would be to put it in a function and call it, passing in the column index you want to filter on, so you don't have large amounts of duplicate code.