fnFilter checkbox

fnFilter checkbox

renato7xrenato7x Posts: 4Questions: 0Answers: 0
edited August 2009 in General
would it like filtering a column with content checkbox with fnFilter, since I do?

Replies

  • allanallan Posts: 63,881Questions: 1Answers: 10,530 Site admin
    Hi,

    Yes, it is possible to filter a column using a check box. If you have a look at the fnFilter API function ( http://datatables.net/api#fnFilter ) you'll be able to see that you could attach an event listener to the checkbox and use that to apply fnFilter().

    Regards,
    Allan
  • renato7xrenato7x Posts: 4Questions: 0Answers: 0
    thank you,

    it worked perfectly
  • mickeymicmickeymic Posts: 23Questions: 0Answers: 0
    I don't understand how I can use fnFilter for filtering a column with checkbox.

    Is it possible to have an exemple ?
  • allanallan Posts: 63,881Questions: 1Answers: 10,530 Site admin
    edited September 2009
    Hi mickeymic,

    It's actually quite difficult to filter on a column with checkboxes in it. The reason for this is that you need to look at the live DOM, rather than the internally cached state in DataTables. It certainly is possible, using the custom filtering options that DataTables provides, but it's non-trivial to do (a reasonably good understanding of Javascript will be required).

    There isn't an example of this available at the moment, but I'll add it to my to-do list (which is rather long now, so it won't be any time soon...).

    Allan
  • mickeymicmickeymic Posts: 23Questions: 0Answers: 0
    Hello Allan,

    OK thank you

    bye
  • dmccleandmcclean Posts: 13Questions: 2Answers: 0
    I would like to also filter on a column with checkboxes. Is the situation described above still true (difficult to
    filter on a column with checkboxes), or has there been any progress on this since the last post?

    Thanks,
    Don
  • dmccleandmcclean Posts: 13Questions: 2Answers: 0
    After thinking about it some more, it seems that if I added a hidden column and updated the hidden column with the value of the checkbox when it changed, I could filter using the hidden column. Would this approach work?

    Also, is there a way to OR the hidden column filter with the global search box? I would like to always display any rows where the checkbox is enabled.

    Thanks,
    Don
  • cicatrizadocicatrizado Posts: 2Questions: 0Answers: 0
    dmcclean did you got it?

    I also need to filter all rows, but always displaying any rows where the checkbox is enabled.
  • allanallan Posts: 63,881Questions: 1Answers: 10,530 Site admin
    > I would like to also filter on a column with checkboxes

    The way to do this is to use a filtering plug-in: http://datatables.net/plug-ins/filtering . With the filtering plug-ins you have full access to the row's data and the nodes for the row - you simply perform your logic on the row and then return true or false to indicate if you want it to be included in the output or not.

    What is the interaction that you are looking for between the filter and the checkboxes? Are you looking for the user to type something that it will match against for checked inputs, or do you have a toggle somewhere which indicates if checks rows should be included or not?

    Allan
This discussion has been closed.