I am trying to filter this table by data attributes, you can find it here:
I managed to get the value of the inputs with text using
$filters.on("keyup", function () {
var $i = $filters.filter(function () {
console.log(this.value);
return $.trim(this.value).length > 0;
})
});
Also was able to get data atributes of those input:
var datattrbs = $i.map(function () {
console.log($(this).val());
return $(this).data('column')
}).get().join(',');
The idea is to hide the rows which does not match all criteria on inputs, filtering by data attributes.
Right now I am stuck on this portion:
$rows.hide().filter(function () {
return $('td', this).filter('td[data-column='+datattrbs+']').filter(function () {
var content = this.textContent;
var inputVal = $i.filter($(this).data("column")).val();
return content.indexOf(inputVal) > -1;
}).length === len;
}).show();
UPDATE I have managed to solve most issues, except filtering by many data attributes:
http://jsfiddle.net/vdbo47xv/
how can I filter by comma separated list: filter('td[data-column=id,articolo]')? is it possible?