KTDatable Multiple Column Search

Hi, may I know how I can perform search on multiple columns with the datable.search() function? Thanks

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (12)

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('');

Thanks

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')
})

Also, is searching on multiple column at the same time possible?

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,

Thanks

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);
})

Thanks

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);

Thanks

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

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(