filter with count

filter with count

TheNerdy97TheNerdy97 Posts: 25Questions: 6Answers: 1
edited October 2022 in Free community support

I have a filter checkbox and it's working perfectly, what I wanted to add next is an input of numbers beside the checkboxes to filter how many of said data to filter.

live example: http://live.datatables.net/xepaduje/3/edit

example: Let's say column 6 is a child row with images if I click the checkbox for image (1222) and input number 1 it will return rows with 1222 existing once or more, and that is the normal behavior, but if the input number is 2 it will search for rows where 1222 exist twice or more this is also working even though it's not on the example, but the problem with this is when you click another checkbox with input number 1 the already clicked checkbox will also become input number 1.

this is the actual code

$('input:checkbox').on('change', function () {
//getting the input number for the specified checkbox

  var x = $(`#count-${this.value}`).map(function(){
      return this.value
    }).toArray().join("")

  var positions = $('input:checkbox[name="Characters_Filter"]:checked').map(function() {
    return '(.*' + this.value + `){${x}}`;
  }).get().join('');
  

  //filter in column 6, with an regex, no smart filtering, not case sensitive
  table.column(6).search(positions, true, false, false).draw(false);
});


Answers

Sign In or Register to comment.