Upgraded to the latest v2.3.2 but shows "Loading..." with deferLoading & an empty tag
Upgraded to the latest v2.3.2 but shows "Loading..." with deferLoading & an empty tag

Debugger code (debug.datatables.net):
Sorry, I tried but it didn't work (the following error was in the console);
Uncaught TypeError: Cannot read properties of undefined (reading 'inArray')
str @ DT_Debug.js?rand=1753309990014:267
stringify @ DT_Debug.js?rand=1753309990014:351
stringify @ DT_Debug.js?rand=1753309990014:625
(anonymous) @ DT_Debug.js?rand=1753309990014:619
Error messages shown:
None
Description of problem:
I've upgraded to the latest version of DataTables (from v1.12.1), but if I have an empty table (ie. <tbody></tbody>), with data-defer-loading="0" (or data-defer-loading="[0,0]") set, it just shows "Loading..." in the body, rather than "No records found" (which is what's shown if I sort a column, or add or change the search field).
I'm using server-side processing, and pre-load the table with data where there is some ... before the upgrade, it's worked without an issue (the empty table would show "No records found") ... but i'm stuck with trying to get this last bit fixed.
Any help would be amazing - you've truly made an incredible contribution to the community, thank you!!
This question has an accepted answers - jump to answer
Answers
I built this test case for you:
https://live.datatables.net/jepubuyo/1/edit
Based on my understanding you have a preloaded
tbody
withdata-defer-loading="0"
and server side processing. This is what I setup in the test case. The test case doesn't result in "Loading..." being shown.Have you looked at the browser's console for errors when this error occurs?
Can you post a link to your page or a test case replicating the error so we can help debug. Feel free to update my test case.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I may have misread your problem description. I saw
and pre-load the table with data where there is some ...
but maybe the table is empty like this test case which showsLoading...
.https://live.datatables.net/jepubuyo/2/edit
See if setting
language.loadingRecords
to set change fromLoading...
toNo records found
will work for your situation. Like this:https://live.datatables.net/tanesoba/1/edit
Kevin
Hi Kevin,
Yes - https://live.datatables.net/jepubuyo/2/ is what's happening to me, where the tbody is empty (ie. no rows), but shows 'Loading'.
Is there any way you've found of including the 'language.loadingRecords' as a data attribute in the
<
table> tag? ... I think it'd be an easy work-around if I can do that.
Thank you again for your help.
Victor
Hi Kevin,
I've managed to make the change in JS which will do for the moment, unfortunately this means the 'Loading' message will then not show for subsequent requests (ie. if a filter is used on page-load, which shows 'No records found', changes/removal of the filters/search will still show 'No records found' instead of the proper 'Loading' message (as we've now set it to show 'No records found' instead of 'Loading').
Hopefully the workaround will suffice while this is fixed up, thank you again for your help.
Thanks,
Victor
I haven't done much testing with
language.loadingRecords
to know when it is displayed. One option might be to use theready()
API and in the function change the text displayed. Inspect the table in this state and you will find atr
andtd
Datatables adds to display this message to the -tag tbody`. Use jQuery or Javascript to change the text. For example:https://live.datatables.net/jepubuyo/5/edit
@allan will need to comment on making changes to the code for this.
Kevin
I'm afraid I don't understand what you mean here. Can you show me a code example?
language.loadingRecords
is only ever showed on first load. It is never used after that - as the docs say:If you want to show that the table is doing something after that
processing
should be used.Allan
See this test case:
https://live.datatables.net/jepubuyo/2/edit
That's what I thought and why I recommended it
Kevin
Many thanks Kevin - I think I'm starting to get it now. I was at a whisky tasting the other night (
) and maybe I've not recovered properly yet (
)!
If I run your test case with DataTables 1.12.1 it shows "No data available in table", but with v2 it shows the "Loading..." message? If I've (finally) understood, that is the problem - the difference between 1.x and 2.x's behaviour there?
Allan