Returning early from fnServerData "Loading..." indicator remains visible

Returning early from fnServerData "Loading..." indicator remains visible

robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
edited March 2014 in General
I'm using 2 data tables in a master-details arrangement where when the user clicks on a row in the master data table, the details data table is reloaded using info from the row that was clicked in the master data table. Both data tables use server side processing.

Here is the fnServerData option for the details data table. I am returning early if there is nothing selected in the master data table. But when i do the "Loading..." indicator is left visible.

Is there a way to prevent this? If I could just do away with the "Loading..." indicator that would be a suitable solution because I already have an ajax loading indicator for the entire page.

Thanks.

Robert

Link to example: http://jsfiddle.net/atomofthought/2Y8SC/

[code]

$(document).ready(function() {
$('#example').dataTable({
"sPaginationType": "full_numbers"
, "sAjaxSource": "ThisWillNeverBeUsedInThisExample"
, "fnServerData": function (sSource, aoData, fnCallback) {
if (nothingSelected == undefined) {
return;
}
// I'd normally call $.ajax() here...
}
});
});
}
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Currently I think you'll need to do `settings._fnProcessing( settings, false )` (where `settings` is the 4th parameter for the fnServerData method).

    Perhaps I should add the ability to return `false` from the function...

    Allan
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    _fnProcessing is not a method of the 4th parameter, ie settings. Did you mean settings.oApi._fnProcessingDisplay(a, b) ?

    I think you are right. Adding the ability to return false would be good in this situation.

    Thanks Allen.
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    The solution, and sorry that I had not tried this before wasting your time... =(

    call fnCallback like this and return...

    fnCallback({
    aaData: []
    , iTotalDisplayRecords: 0
    , iTotalRecords: 0
    , sColumns: null
    , sEcho: "0"
    });

    return;
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > Did you mean settings.oApi._fnProcessingDisplay(a, b) ?

    Oops! Yes. That's the one :-). First argument to _fnProcessing display is the settings object and the second a boolean.

    Allan
  • robertbrowerrobertbrower Posts: 158Questions: 1Answers: 0
    oSettings.oApi._fnProcessingDisplay(oSettings, false) doesn't do away with the "Loading..." indicator. But my above solution is a suitable workaround.
This discussion has been closed.