Male and Female Filtering

Male and Female Filtering

erickaxerickax Posts: 1Questions: 1Answers: 0

I've seen two similar problems with what I have now, but I don't get what and where and how they do it to make theirs work. Like where do they put those code? I really don't get it :(

First is this -> https://datatables.net/forums/discussion/15604/gender-filtering-male-female

Second is this -> https://datatables.net/forums/discussion/460/fnfilter-problem/p1

I have a Gender column on one of my tables. When I type "Male" in the textbox search of datatables, it filters both "Female" and "Male" . How to fix this problem? I want that when I type "Male", only those with that record wil show up. I am using datatables version 1.10.11

Answers

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin

    If you are using client-side processing, then you could use a regular expression (i.e. ^male) to match only "Male" when using column().search().

    If you are using server-side processing then you need to do something similar in your server-side script (probably remove the leading wildcard).

    The next major version of DataTables will match the start of words only automatically (client-side processing).

    Allan

This discussion has been closed.