Columns Individual Search
Columns Individual Search
svrp
Posts: 4Questions: 1Answers: 0
Hi.
I'm trying to make a column search for individual columns
https://jsfiddle.net/gdzjpcv4/1/
And I have this code that is called on a document ready function from jquery.
However, when I start searching on one of these fields, my table disappears. Any help on this?
Thank you.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You can't add a footer after DataTables has been initialised. What you'll need to do is add the header first (or put it in the HTML) - then clone that, insert the input elements and then finally initialise the DataTable.
Allan
Hi Allan,
Thank you for your reply.
I already tried that and I put the inicialization of headers on HTML, however, as you can see here: https://jsfiddle.net/4pLg6xdr/1/
The same happens, even without that clone. The table disappears when I start writing on the search inputs.
One more example,
I tried to modify I bit.
https://jsfiddle.net/4pLg6xdr/5/
I delete some scroll functions and now the table does not disappear but It does not make the search properly (it does not appear the row that I search).
I'm doing anything wrong?
the colIdx gives me the correct value and also the this.value of my search.
As you can see in your debug, your searching on both columns - your code becomes
DataTables searches are ANDs - so as it's looking for the same string in both columns, nothing is matched. You need to search on the one column where the input element is.
This example is doing what you want to do: https://datatables.net/examples/api/multi_filter.html
Colin
Yes it was that the problem.
I made an example with the solution, so I can help any other with the same problem:
https://jsfiddle.net/4pLg6xdr/5/
The working solution is on the link above. Thanks.