Make a checkbox which filters content from table

Make a checkbox which filters content from table

ggiavelliggiavelli Posts: 5Questions: 3Answers: 0

I'd like to make a checkbox which filters out all rows which have a column of a set value from display in the table. But so that it works like a show/hide function on those rows, but still allows the regular search to happen.

Answers

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited June 2019

    A search plugin will work well for this. Here is an example I created previously.
    http://live.datatables.net/rosahuka/1/edit

    Kevin

    EIDT: Added link to search plugin docs.

  • ggiavelliggiavelli Posts: 5Questions: 3Answers: 0

    Thanks Kevin, that's it exactly. Muchos appreciados

  • Pedro NeffPedro Neff Posts: 3Questions: 1Answers: 0

    Hello kthorngren how would i do the exact opposite i need to hide rows that have a value by checking a checkbox

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited July 2019

    The search plugin docs describe how to control which rows are displayed:

    The plug-in search function should return a boolean value:
    true - The row should be included in the search results
    false - The row should be removed from the search results

    Here is the updated example - return false if there is a match to hide the row:
    http://live.datatables.net/bohaqeho/1/edit

    Kevin

  • Pedro NeffPedro Neff Posts: 3Questions: 1Answers: 0

    Thanks Kevin!

This discussion has been closed.