Filter OUT - hide/show

Filter OUT - hide/show

bcraigbcraig Posts: 8Questions: 2Answers: 0
edited June 2014 in Free community support

I would like to know how I can filter OUT rows of my table to show and hide them depending on the state of a checkbox.
If my 'Hide' checkbox is checked then hide rows where class=var and if checkbox is not checked show rows where class=var

I have setup a small demo with the ability to hide/remove the rows I want but this doesn't allow the rows to reappear.

http://jsfiddle.net/bcraig/cY8Cn/2/

Replies

  • dtimpermandtimperman Posts: 6Questions: 2Answers: 1
    edited June 2014

    Hello, I used this in datatables 1.10:

        // Add Custom filtering function which will search data in columns 
        // This is only used in case of clientside processing. 
         $.fn.dataTable.ext.search.push(
         function(settings, data, dataIndex) {
             var sku = ("" + (data[0])).toUpperCase(); // use data from the '0'-indexed column
             var skuFilter = ("" + $('#skuFilter').val()).toUpperCase();
             var skuMatch = false;
             if (skuFilter === "" || sku.substr(0, skuFilter.length) === skuFilter) {
                 skuMatch = true;
             }
     
             var descr = ("" + (data[1])).toUpperCase();
             var descrFilter = ("" + $('#descriptionFilter').val()).toUpperCase();
             var descrMatch = false;
             if (descrFilter === "" || descr.indexOf(descrFilter) !== -1) {
                 descrMatch = true;
             } 
    
            var dec = "" + (data[31]);
             var hideDecided = $('#decisionFilter').is(':checked'); //decFilter = checked -> hide decided
             var decMatch = true;
             if (hideDecided === true && dec.trim().length !== 0) {
                 decMatch = false;
             }
     }
     
     return skuMatch && descrMatch &&decMatch; // if this evaluates to true the column is shown
     }
     );
    
This discussion has been closed.