Display missing record in the result
Display missing record in the result
Do you know if it's possible to have the list of missing records (records not found from a query) in the result of the table?
For example i have a mysql table with the following records
NAME
paul
paul
paul
John
John
Anne
Then if i create a query by searching "Paul"
I will have the result of 3 rows (paul, paul, paul)
Great but if i search
"Paul + Marc"
I would like to have the following result:
Paul
Paul
Paul
No value found for "Marc"
possible?
I used the zeroRecords item but works only if i search for missing records... not when i search for both (missing + present)
Thanks for your help
This question has an accepted answers - jump to answer
Answers
to be more precise, the rusult in case of missing records should be:
Paul
Paul
Paul
and on the bottom something like:
"sorry, no records found for Marc"
so only one string that advise the user for unfounded records (in this case 'Marc')
There is
infoCallback
which can be used to customise the message shown at the bottom of the table. However, you'd need to write the logic to determine what values found no search results. That isn't something that DataTables would do I'm afraid. You'd need to get the search term, loop over the records that DataTables found and see what term it matched on.Allan
thans @allan for your reply.
Do you have an example how to customize the infocallback? I can store the result into a variable... if you give me a basic example i can customize by myself
The documentation has two simple examples of how it can be used. I pasted one in here so you can see it running: http://live.datatables.net/tubeyahe/1/edit .
Allan
and if i have the result passed from ajax call? How to catch it and add to infocallback?
Are you using
ajax
andajax.reload()
to fetch the data with the search term?If you are using a jQuery ajax() request then likely you will need to update the info element your self. Or maybe use
draw()
to haveinfoCallback
run.The answer depends on how you are doing this. If you still need help then please post the relevant Javascript code showing what you are doing.
Kevin