The datatable I’m creating has a “Sex” column. Here is the filter..
columnFilter({
aoColumns: [ { type: "select", values: [ 'Male', 'Female' ] },
{ type: "text" },
{ type: "number" },
{ type: "number" }]
});
The problem is that the word “male” is in the word “Female” so when I select the “Male” filter it shows all. Is there a way to have this select exact match or even at least case sensitive?
The Columnfilter plugin uses the datatables API function
fnFilterto do its individual searches. According to the author’s documentation (the little there is) he seem to have forgotten the case sensitive parameter in thefnFilterfunction(search for fnFilter), and the plugin doesn’t give much leeway for the filter settings.There are a few alternatives.
You could design your own filtering plugin, utilizing the
fnFilterfunction, now that you know that it’s there.You can do some ad-hoc solutions, like in this example. Note that this is a very lazy example, but it shows how the plugin basically works.
If you’re up for it, you can alter the filtering in the plugin code. This is what I recommend, because it’s an easy fix.
Adding/changing these lines in
datatables.columnFilter.jsshould be enoughThose
.fnFilters should be enough to get what you want. There are plenty more in there, so if you want to add it on the others as well, just do the same thing.All I did was add a default parameter called
bCaseSensitivethat you can now enter in the options and then added the same parameter to the functions that created the events and of course, added it to the.fnFilterfunction itself.Best of luck!
If you can’t get it to work, I’ll see if I can upload the altered plugin somewhere for you to download from.