How do I add checkbox filtering to a DataTable?

How do I add checkbox filtering to a DataTable?

neelam_citeneelam_cite Posts: 6Questions: 2Answers: 0

I would like to add checkbox filters, I have created an example here: https://jsfiddle.net/4xpskzd9/3/ however I'm not sure what I might be missing as my checkbox filters always return 0 results.

I found some useful questions already asked (https://datatables.net/forums/discussion/53741) that are similar to what I would like to achieve but I cannot them to work.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,308Questions: 26Answers: 4,769
    Answer ✓

    You are referencing rowData[0] (first column) not rowData[4] (fifth column). Try making this change:

            if (elem.checked && rowData[4] === elem.value) {
              found = true;
            }
    

    Kevin

  • neelam_citeneelam_cite Posts: 6Questions: 2Answers: 0

    Thanks, that worked.

    However I will be adding multiple checkboxes, is there a way to do this more programatically?

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    There's an example in this thread here - see my last comment. Hopefully that'll get you going,

    C

  • kthorngrenkthorngren Posts: 20,308Questions: 26Answers: 4,769

    You may be interested in this thread too. Its a simplified version of Colin's example. Just more options to show how this can be done :smile:

    Kevin

This discussion has been closed.