DataTables processing message

DataTables processing message

harmenzonharmenzon Posts: 17Questions: 7Answers: 0
edited October 2018 in Free community support

I am loading my data through an Ajax call. This works fine and the data is loaded after some time.
During this time the DataTable shows the message "No data available in table". So it is showing the "emptyTable" message.
While I would actually like it to show a "processing" or "loadingRecords" message. I have included the option "processing: true". Should this not be enough? Or am I missing something?

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @harmenzon ,

    I would expect it to show "Processing" as you said, see this 'faked' example here.

    We're happy to take a look. As per the forum rules, if you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • JCHJCH Posts: 2Questions: 0Answers: 0

    I am experiencing this too. I do not know the dataTables library, so I apologise in advance if this is a massive fail. I have tracked down a potential source of the problem on approximately line 3490 of DataTables 1.10.18:

    if ( (oSettings.iDraw == 1) &&  _fnDataSource( oSettings ) == 'ajax' )
    {
        sZero = oLang.sLoadingRecords;
    }
    else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
    {
        sZero = oLang.sEmptyTable;
    }
    

    This code is running 3 times in quick succession, incrementing iDraw each time. I have tested the following change to the first line which seems to make a difference:

    if ( (oSettings.iDraw == 1 || oSettings.iDraw == 2 || oSettings.iDraw == 3) &&  _fnDataSource( oSettings ) == 'ajax' )
    

    However, as I do not know the consequences of this change I am wary of it being VERY wrong. Hopefully someone will be able to spot the actual problem.

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin

    Can you link to a page showing the issue please? If you are using ajax to load the data, DataTables should show a "Loading..." message in the table during the first load.

    Allan

  • JCHJCH Posts: 2Questions: 0Answers: 0

    Found the problem (whilst trying to break apart my application to create a page demonstrating the issue).

    I don't know if it was worth it.....!

    I had created a form that controlled the table. Changing the form would fire off a search trigger:

    table.columns(0).search($('#whatever').val()).draw();

    The form was dynamically loaded/selected depending on some URL variables (and some select inputs had options dependent on the value of other selects). The aim being to filter the table straight away and on subsequent changes to the form. But during this loading process the search was firing

    I.e. on change the select drop down:
    - prepare the options in the second (dependent) select input
    - filter the table on the basis of the value in this drop down

    But this was firing when the page first loaded .......which was redrawing the DataTable.....before the ajax call had completed.......which was giving the "This table is empty" message before the data arrived.

    So the resolution was a simple

    if(!firstTime)
    {
        table.columns(0).search($('#whatever').val()).draw();
    }
    

    ...and then filter the table once the Ajax call had completed.

    Apologies for wasting everyone's time.

This discussion has been closed.