Search Multiple results
Search Multiple results
mattbrown
Posts: 5Questions: 1Answers: 0
Hi EveryOne I am new to datatables hence want to ask a simple question:
('#example').dataTable({"search": {regex: true}}).search("London|Tokyo", true, false ).draw();
when i do this I get perfect results but I dont want to put hardcoded data but the dyanamic one that comes from search box.
In case of Dynamic Values it only searches for value before "|" character.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
See if this example helps:
https://www.datatables.net/examples/api/regex.html
Kevin
I tried Based on link you gave but didn't get results
function filterGlobal () {
$('#example').DataTable().search(
$('#global_filter').val(),
true, false
).draw();
}
$(document).ready(function() {
$('#example').DataTable();
$("#example_filter input").prop( 'id','global_filter' );
$('#global_filter').on( 'keyup click', function () {
filterGlobal();
} );
});
I dont want to create a new search box but use the default one
Hey Kevin thanks for that link it solved my issue but just wanna ask if instead of "|" can If I want to use "," is that possible....
Many thanks you are saviour
Yes you can. Maybe you can take
$('#global_filter').val()
and replace the,
with|
and perform the search.I've used the search plugin for this type of search. It may be a good option for you depending on the complexity of what you are trying to do:
https://datatables.net/manual/plug-ins/search
Kevin
That's good idea thanks...