DataTable search filter is always returning “No matching records found”
DataTable search filter is always returning “No matching records found”

I want to filter result records by a keyword. But when I enter a keyword, data-table always display "No matching records found" message.
It should display related record matching keyword typed by user.
LIVE Demo: http://live.datatables.net/payuteka/1/watch?html,css,js,console,output
Not sure my HTML markup is missed up or what can be the issue that search filter isn't working?
This discussion has been closed.
Answers
Formatted demo http://live.datatables.net/havusebu/2/watch
UPDATE: In my HTML I have used data- attributes for filtering records which is causing the issue. But why will data-search attribute cause this issue? By removing the below data-search attributes search filter is working. But when data-search= is present in the HTML it's not working.
<td data-search="blog">
This is due to orthogonal data.
results in the string
blog
being returned whenever a search occurs, and not the string in the cell itself.Colin
Hi @colin ,
Yes I know that it's due to
<td data-search="blog">
but how can I make it working?I want the filters and search filter also. By search filter I mean when user types a keyword in search box.
Best regards
What is your goal with this?
Maybe you need two columns. One for the regular search and one with
data-search="blog"
. One of the columns can be hidden with `-option columns.visible.Kevin
@kthorngren I do filtering by data-search attribute please see the attach
My suggestion is to have a hidden column with a flag indicating if the row is a blog or not. You can use
columns.render
to look at the row data to determine if its a blog.Kevin
@kthorngren this is how currently filtering is working:
HTML:
Let say If I changed <td data-search="{{ hit['_source']['filter'] }}"> to <td data-searchFilter="{{ hit['_source']['filter'] }}">
So how can I bind search filter with this then?
Hi,
I'm not quite clear on what it is you are looking to do I'm afraid, so I'm not sure how to resolve it. If you have
data-search
attributes fortd
elements, DataTables will use their value as the search string.I'm presuming that is not what you want.
Do you want DataTables just to search the content of the cell? If so, change
data-search
todata-searchFilter
as you say, and it will just use the content of the cell.Allan
Yes I want to search the content when some type a keyword in search input.
But I also want the checkbox filters to be working. e.g if someone check
Blogs
checkbox it should just show the blogs records from the result. And these filters works ondata-search
now. So if I remove/rename data-search to something else then this filtering functionality will be broken.Best regards
Sounds like using the HTML5 data attribute for searching isn't going to work for your case. Here are a couple examples of using checkboxes for searching.
Uses a function:
http://live.datatables.net/vipifute/1/edit
Uses a Search Plugin:
http://live.datatables.net/wenaxuti/1/edit
Maybe one of these will help you adapt your checkbox search.
Kevin
Hi @kthorngren @allan @colin ,
Thanks for the help guys.
I just added an extra hidden td
<td style="display:none;" data-search="{{ hit['_source']['filter'] }}"></td>
and removeddata-search
from the belowtd
and now both filter and search is working
Thanks a lot guys.
Code LIVE Update: http://live.datatables.net/jitaguce/1/watch
Best regards