Filtering on checkbox

Filtering on checkbox

rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
edited December 2011 in DataTables 1.8
I have a column that is just checkboxes. I also have filtering on each column enabled. How can I filter the checkbox column to show only those that are checked?

Thanks,

-Rhon

Replies

  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    Anyone?
  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    I was able to get filtering on checkboxes working. Below is the code I pieced together.

    [code]/* FILTER BASED ON CHECKED ITEMS */
    //
    $('#checkbox_filter').click( function() { oTable.fnDraw(); } );
    /* Custom filtering function which will filter data in column four between two values */
    $.fn.dataTableExt.afnFiltering.push(
    function( oSettings, aData, iDataIndex ) {

    if($('#starfilter').attr('checked')){
    if($('input', oTable.fnGetNodes(iDataIndex)).is(':checked')){
    return true
    }
    }
    else {
    return true
    }
    }
    );
    //
    /* END OF CHECKED FILTER */
    [/code]

    In my footer, the checkbox column, I put a checkbox with an id of checkbox_filter. When that checkbox is clicked, the code above runs.
This discussion has been closed.