Display missing record in the result

Display missing record in the result

m75sam75sa Posts: 132Questions: 30Answers: 0
edited January 2023 in Free community support

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

  • m75sam75sa Posts: 132Questions: 30Answers: 0

    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')

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    and on the bottom something like: [...]

    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

  • m75sam75sa Posts: 132Questions: 30Answers: 0

    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

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    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

  • m75sam75sa Posts: 132Questions: 30Answers: 0

    and if i have the result passed from ajax call? How to catch it and add to infocallback?

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Are you using ajax and ajax.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 have infoCallback 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

Sign In or Register to comment.