Hi, may I know how I can perform search on multiple columns with the datable.search() function? Thanks
Ahh, and also, how can I clear my search result & reset the table after performing .search()?
Hi,
Can you please provide more info ? Are you using KTDatatable with Metronic 7.x ?
Regards.
Sorry, yes, Metronic 7.X with Laravel
Hi Gabriel,
You can try to input empty strings to reset the search.
datatable.search("");
Ahh, I realise I had to press 'Enter' for the search to trigger although I placed the function in 'keydown'. Do you know why?
This is my code:
$("#search").on("keydown", function(e) {
datatable.search(e.target.value, "ColName")
})
Hi Gabriel,
Could you please check the config here if there is onEnter: true
option enabled?
search: {
// enable trigger search by keyup enter
onEnter: false,
Hi, nope, I am not using the search config as I am planning to programatically call the search function
Have you checked if this event is triggered?
$("#search").on("keydown", function(e) {
console.log(e);
})
Yes, it is trigerred. It seems like the search is being delayed.
For example:
When I type "a" in the searchbox, the event is trigerred but search() wasn't searching. Then I backspace on the "a" which clears the searchbox and at this time, search() will perform search on records containing "a" value @@
Anyway, this isn't a major concern. Appreciate if there's a solution for my another problem: Searching on multiple column at the same time
Leave the column name param empty will search in all columns.
datatable.search(e.target.value);
Ahh, cannot particularly set to search for like 2 columns only out of 6? The reason I am not using config search is because I only wanted to search in 2 particular columns
Hi Gabriel,
Sorry for the inconvenience. Please consider using datatables.net. It should support multiple column searches and many more features. And it has more detailed documentation.
Thanks