Individual column searching (select inputs) - How to clear inputs
Individual column searching (select inputs) - How to clear inputs
peterstilgoe
Posts: 22Questions: 6Answers: 0
Hi
I am using the Individual column searching (select inputs), what code do I use to clear the input values in the drop downs ?
I clear the search box using: $("#example").DataTable().search("").draw();
But having trouble working out how to clear the dropdown filters in a similar manner ?
Cheers
This question has accepted answers - jump to:
This discussion has been closed.
Answers
DataTables doesn't control the input elements used for column searching, so it can't know what it should clear. You would need to clear your input elements yourself using jQuery or DOM methods.
Allan
Hi,
I am specifying my dropdown using:
And clearing it using:
Its clearing the drop down making it blank but the datatable is still filtered by whatever was selected previously.
What command do I need to use to clear the DT of the actual filtering so it displays all the data that exists in the table ?
Cheers
Try:
which will trigger your
change
change handler (presumably that is what you are listening for to filter the DataTable).Allan
Hi
Basically Im using the A - Z alphabet search as in the the blog posts, when I click on a A - Z letter this is when I want to clear the filter column:
Adding .change() creates "Cannot read property 'replace' of null"
Happy to take a look if you link to a page showing the issue.
Allan
Hi.
Unfortunately using O365 so it wont work for you, the code is below but probably doesn't help you:
It works in the Dev Tool Bar eg.
$("#mySelect").val('BRRS'); - Updates in the browser as expected & updates the DT with the new filter value & result set
Are you able to use JSFiddle, JSBin or https://live.datatables.net to show an example with the issue?
Allan
Hi Allan,
See the issue here: http://live.datatables.net/besikoki/1/edit?js,output
Cheers
I'm getting an error on that page:
I don't think we've discussed that problem above. Is that an issue only in this test case or is it a problem you are seeing on your page as well?
Allan
Yes its the same error on my sharepoint page and in the test case.
Basically Im using the A - Z alphabet search as in the the blog posts, when I click on a A - Z letter this is when I want to clear the filter column.
When I add $("#mySelect").val([]).change(); in the AZ click event it clears the drop down but not the actual filter. In dev toolbar displays
Uncaught TypeError: Cannot read property 'replace' of null
Cheers
If I just use:
$("#mySelect").val([]);
A-Z & filtering works together but it does not clear the actual filter:
http://live.datatables.net/besikoki/2/edit?js,output
Any ideas why the filter doesn't clear in this instance ?
Thanks
It works with:
http://live.datatables.net/besikoki/3/edit
Allan
Thank you