create select type filter by checkboxes columns

create select type filter by checkboxes columns

iamtechnomageiamtechnomage Posts: 3Questions: 1Answers: 0

Link to test case: https://live.datatables.net/nakitire/1/edit?html,js,output

Description of problem: try to create custom filter for Authorization and Cached columns (checkbox values).
i create input type=select with 3 options Yes, No and All, but cant uderstand realisation of this filter.
read some topics on forum but all of this "how to filter use checkbox"

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,995Questions: 26Answers: 4,887

    Maybe this demo will help:
    https://live.datatables.net/cefadoze/3/edit

    It shows two ways to filter based on checked or unchecked. One way uses a search plugin, similar to your test case. This uses one search plugin instead of pushing and popping the plugins. Pushing and popping the plugins might become problematic especially if you decide to add search plugins for other columns.

    The other uses column().search() to find checked/unchecked. It relies on setting.a data value for the column based on whether its checked or not.

    Let us know if there are any questions.

    Kevin

  • iamtechnomageiamtechnomage Posts: 3Questions: 1Answers: 0

    Thank you, its looks better.
    But now i stuck with other issue.
    Table not reset context after change filter options in Authorized and Chached
    if i pick first Yes option, after that pck No option, i get empty table.
    but if use ext.search.pop() cant combine two filters.
    please tell me, how i can fix this?

    https://live.datatables.net/teyozequ/1/

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin
    Answer ✓

    Don't add a new function to $.fn.dataTable.ext.search every time an option is selected. It it would mean you need to keep track of the added functions and remove them as needed. That's possible, but it can be a little tricky.

    What I tend to do is add a search function once (in this case you've have two since you have two different filters) and then set values that the functions have access to and can perform filtering on.

    Much easier to keep track of the filtering this way.

    Allan

  • iamtechnomageiamtechnomage Posts: 3Questions: 1Answers: 0

    thank you Alan, is been really tricky. but your advise help me so much.

    all works.
    thnak you all

Sign In or Register to comment.