Loading AJAX dataset: no "processing" state, only "No data available in table"

Loading AJAX dataset: no "processing" state, only "No data available in table"

iain_mciain_mc Posts: 15Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
I have this in my table definition:

[code]oLanguage: { sProcessing: "" },[/code]

But whilst the table is gathering data from AJAX (which displays fine, after about three seconds) there is no indication of life, only of an empty table ("No data available in table") which is a little disconcerting.

Can I force it to show it's processing state on initial load?

Thanks!

Iain

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Assuming the image file is there, that looks like it should work okay to me. Are you sure the image is loading before the data? I'm just wondering if the gif takes longer to be downloaded that the data from the server!

    Try adding a bit of text to the string and seeing if that shows up as well.

    Also, I presume you are using sAjaxSource to load the data?

    Allan
  • iain_mciain_mc Posts: 15Questions: 0Answers: 0
    edited January 2013
    Hi Allan,

    Even if there's no image specified (and I only use text) I get the same result.

    [code]
    dTable=$('#worklog').dataTable({
    bJQueryUI: true,
    iDisplayLength: 100,
    aaSorting: [[ 0, "desc" ]],
    bSortClasses: false,
    oLanguage: { sProcessing: "Test....." },
    sAjaxSource: "./worklog.ajax.php",
    sDom: '<"H"Tfr>t<"F"ip>',
    aoColumns: [...
    [/code]

    The DataTable is loaded in a jQuery tab and defined in the (document).ready function.

    It's a reasonably sized dataset (c.3,000 rows) but nothing spectacular.

    The plot thickens: I have some fnFilter actions occurring on a couple of lines after the table definition to pre-filter on the page.

    If I remove those, I get the "loading..." message in the DataTable (but still not my custom sProcessing message). If I put them back, it's back to "no data available" (I really need the pre-filter).

    Cheers, Iain

    PS. Just having the "loading..." message would be fine if the other is not practical.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Ah - so do you have something like this:

    [code]
    dTable=$('#worklog').dataTable({ ... });
    dTable.fnFilter( ... );
    dTable.fnFilter( ... );
    [/code]

    ?

    If so, that's the problem - remember that the Ajax load is async, so while the data is still being loaded, the filter will be getting applied. When the filter is applied, it will hide the processing message (since the filter thinks it is done). DataTables could keep an internal nesting count of what has requested the processing message to show, but I suspect that way could throw up more edge cases.

    What I would suggest, if you want to apply initial filters, is use the initial filtering options - aoSearchCols and oSearch . That will be applied immediately to the table.

    Allan
  • iain_mciain_mc Posts: 15Questions: 0Answers: 0
    Yup, that's exactly what I have.

    Using aoSearchCols has put the "loading..." message back on initial load.

    Thanks for the quick response!

    Cheers, Iain
This discussion has been closed.