DataTable.draw() not displaying "No matching records found" when search done and empty

DataTable.draw() not displaying "No matching records found" when search done and empty

johnfolljohnfoll Posts: 8Questions: 1Answers: 0
edited January 2023 in Free community support

Description of problem: Use can query data by drop downs, and in some places typing in Search Criteria. Then the JavaScript eventually calls DataTable.draw(). It only displays nothing if nothing found. In the examples on this site, many of them that allow for queries will display "No matching records found" if nothing found. I need for it to work like that. I have tried stuff like this to no avail:

            language: {
                searchPanes: {
                    i18n: {
                        emptyMessage: "</i></b>No results returned</b></i>"
                    }
                    //emptyMessage: "</i></b>No results returned</b></i>"
                },
                infoEmpty: "No results returned",
                zeroRecords: "No results returned",
                emptyTable: "No results returned",
            },

This question has accepted answers - jump to:

Answers

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

    Use language.zeroRecords to customize the message displayed when no records are found when searching. For example:
    http://live.datatables.net/zipabapu/1/edit

    If this isn't working for you then we will need to see an example showing the issue to help debug. Please post a link to your page or test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

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

    Btw - your HTML is invalid there. It should be:

    "<i><b>No results returned</b></i>"
    

    You could also use CSS to get that effect.

    Allan

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    I was already trying that before I posted. By doing the custom search and Draw() it may have prevented that functionality from working. I could not aces your first web link.

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    So my html was invalid. But even invalid html usually displays. Nothing was displayed.

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    Fixing html does not fix the problem as I suspected. Invalid Html still usually displays. I fixed to <i><b>No results returned</b></i> still does not work.

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

    Your code snippet seems works here:
    http://live.datatables.net/ferubaku/1/edit

    I could not aces your first web link.

    You browser might be using SSL and changing the HTTP to HTTPS. Try a differnent browser that allows using HTTP.

    Please update the test case or provide a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    Kevin that example is not using Draw(). The code I am working on does some custom stuff then a .Draw to do the custom search. I need an example that does a custom search and a .Draw()

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

    Ok, I added a custom search and it still seems to be working:
    http://live.datatables.net/ferubaku/2/edit

    Please update the test case or provide specific steps to recreate the issue.

    Kevin

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    Thanks Kevin. I will need to see how to get our code working and different method.

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0

    Ahh I see that "No results returned" was there, but it was hidden from the user. I used the Google Chrome debugger at run time to see this. dataTables_empty class might be the culprit.

    .user-support .dataTables_empty {
    visibility: hidden;
    }

  • johnfolljohnfoll Posts: 8Questions: 1Answers: 0
    edited February 2023

    Thanks Kevin. You showed me that it could work. I was able to find the problem - someone had deliberately hide it in one of our .css files.

Sign In or Register to comment.