Reputation: 1741
I'm not sure if I'm not getting my regex correct or if I'm not understanding how to get datatables to accept my search.
jsfiddle: http://jsfiddle.net/zatvo506/2
I am trying to be able to filter/search on column 1 (Date / Time) so that when I click Search 1 both records are shown.
in a nutshell, I'm trying to figure out the correct way to this:
data_table.column(1).search('01|02', true, true).draw()
and have all rows with either 01 or 02 be shown.
In my fiddle, only the row containing 01 is shown.
Upvotes: 2
Views: 64
Reputation: 33933
My previous answer was wrong... Even if the updated Fiddle looked convincing.
You were correct with .search('01|02', true, true)
or .search('REC|SHP', true, true)
There are 4 possible arguments:
So... There is no need to actually format it a a "real" regex... The second argument takes care of it.
You made me learn something new about DataTables here! Thanks!
Now, I scratched my head quite a time and hallucinated gremlins since the search seamed to work oddly...
I finally noticed the CDN you are using:
https://cdn.datatables.net/v/bs4/dt-1.10.18/r-2.2.2/datatables.min.css
I replaced it with:
https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.19/js/jquery.dataTables.min.js
(Also changed the .css CDN.)
And the gremlins all dissapeared... See this CodePen. So I think that should be your solution.
I can't explain much... The release notes aren't very detailled.
Upvotes: 3