Static Search Box - Clicking the X Does Not Work
Static Search Box - Clicking the X Does Not Work
adh7363
Posts: 3Questions: 2Answers: 0
I have added a static search box and the search feature is working fine, however when I hover over the search box an X appears on the right side and when I click that X the grid search is not cleared. How can I wire up this X feature to clear the data table?
Answers
document.getElementById('mySearch').addEventListener("search", function (event) {
if (!event.target.value) {
myTable.search(this.value).draw();
}
});
I think you will want to use the search event which should also fire when the clear control is fired. The value should be en empty string. When
search()
orcolumn().search()
is passed an empty string the search will be cleared.If this doesn't help then please provide a simple test case showing the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin