Custom Filter using ext.search help

Custom Filter using ext.search help

agreenspanagreenspan Posts: 11Questions: 3Answers: 0

I am trying to make a custom filter/search for multiple checked values, but nothing is happening.

  $.fn.dataTable.ext.search.push(
    function( settings, data, dataIndex ) {
      var selected_rarities = [];
      if ($("#special").is(":checked")) {
        selected_rarities.push(1);
      };
      if ($("#mythic").is(":checked")) {
        selected_rarities.push(2);
      };
      if ($("#rare").is(":checked")) {
        selected_rarities.push(3);
      };
      if ($("#uncommon").is(":checked")) {
        selected_rarities.push(4);
      };
      if ($("#common").is(":checked")) {
        selected_rarities.push(5);
      };
      if ($("#basic").is(":checked")) {
        selected_rarities.push(6);
      };
      var rarity = parseInt( data[1] );
      if ($.inArray(rarity, selected_rarities)) {
        return true;
      } else if (selected_rarities.length == 0) {
        return true;
      } else {
        return false;
      }
    }
  );

Answers

This discussion has been closed.