Show/ hide rows based on a row cell's content

Show/ hide rows based on a row cell's content

nathan1812nathan1812 Posts: 17Questions: 7Answers: 0

Link to test case: http://live.datatables.net/nelujavu/48/edit

Description of problem:
Hi there,
I found this example very similar to the current project that I'm working on so I have modified the table content a bit just to fit my needs. And instead of the "show only used" by ticking checkboxes of the column "Use", I would like to show only "not full quantity" based on column "Qty". For example, if ticking the button, the desired output should be only rows 2, 4, 8, 9 and if unticking the button, it will show all rows again. Any help would be greatly appreciated!

Thanks

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    edited April 2022 Answer ✓

    You could do something like this : http://live.datatables.net/nelujavu/51/edit . It's checking for the presence of the '/', or whether the two numbers match,

    $.fn.dataTable.ext.search.push(
        function( settings, searchData, index, rowData, counter ) {
          var data = rowData[3].split('/');      
          var complete = false;
          if (data.length === 1 || data[0] == data[1]) {
            complete = true;
          }
          var ShowAll = !$('#showused').is(':checked');
          if (ShowAll || complete)
          {
              return true;
          }
          return false;
        }
    );
    

    Colin

  • nathan1812nathan1812 Posts: 17Questions: 7Answers: 0

    Thanks so much, Colin! Also, my apology for duplicating my question in the forum. If possible, please delete the other identical question. Have a good day, sir!

Sign In or Register to comment.