I have a table with some data,
and i want to have ability to make search like enter to names of cities like Paris Berlin so it will show result based on separated words
Hope you can help me
This question has an accepted answers - jump to answer
Hi @artem4ik19 ,
You can do this with a regular expression search - take a look at the search examples here. On the top search, check "Treat as regex" and enter "(tokyo|london)" (without quotes) and both will be matched.
As this isn't intuitive for the average user, you should create your own search input element (as in the example) and just generate your own regex before submitting to search().
Hope that helps,
i created inputwith id global_filter and added function on keyup for it
but it doesnt work when I input two cities
https://datatables.net/reference/api/search()#Example here no normal example, also was searching in internet and no info how to realize this functionality =(
Take a look at this example here - I think this will do what your'e after. Here, if you enter "London Edinburgh" it will show only those two values.
@colin I copied full code on my site and it works
But when I use my own data from mySQL
It doesnt woek. So maybe it works only with static data?
Yep, the demo server-side scripts don't support regex searches, as it is expected the data set will be too large and this would cause a performance issue.
If your data set isn't large, you could disable serverSide, and then the search would work. It really depends on how much data you have, or expect to have in the future.
@colin THank you so much for help. Now it works
It looks like you're new here. If you want to get involved, click one of these buttons!
DataTables designed and created by SpryMedia Ltd.
© 2007-2018 MIT licensed. Our Supporters.
SpryMedia Ltd is registered in Scotland, company no. SC456502.