Show spinner when we call fnReloadAjax function and unnecessary alerts

Show spinner when we call fnReloadAjax function and unnecessary alerts

raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
edited March 2014 in DataTables 1.10
Hi Allan,

I am using dataTable 1.10 beta 2 version to load data from server side using sAjaxSource
[code]
var oTable = jQuery('#example').dataTable( {

"sAjaxSource": "<%=getPatientDataAjax%>",

"sDom": '<"#table_header"<"#inner_table_header"<"filtertx">fC<"filterbtn">>>tiplr',
"bDeferRender": true,
"bProcessing": true,
"oLanguage": {
"sSearch": "",
"sLoadingRecords": "Please wait - loading...",
"sProcessing": ""
}

});
[/code]

code for fnReloadAjax
[code]
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
// DataTables 1.10 compatibility - if 1.10 then versionCheck exists.
// 1.10s API has ajax reloading built in, so we use those abilities
// directly.
if ( $.fn.dataTable.versionCheck ) {


var api = new $.fn.dataTable.Api( oSettings );
if ( sNewSource ) {
api.ajax.url( sNewSource ).load( fnCallback, !bStandingRedraw );
}
else {
api.ajax.reload( fnCallback, !bStandingRedraw );
}

return;
}
if ( sNewSource !== undefined && sNewSource !== null ) {
oSettings.sAjaxSource = sNewSource;
}
// Server-side processing should just call fnDraw
if ( oSettings.oFeatures.bServerSide ) {
this.fnDraw();
return;
}
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
var iStart = oSettings._iDisplayStart;
var aData = [];
this.oApi._fnServerParams( oSettings, aData );
oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
var aData = (oSettings.sAjaxDataProp !== "") ?
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
for ( var i=0 ; i

Replies

  • allanallan Posts: 61,746Questions: 1Answers: 10,111 Site admin
    From the code you posted, it suggests that DataTables 1.10 isn't showing the processing indicator on ajax reload. I will look into this when I get in the office tomorrow morning and hopefully fix the issue.

    There is no code in DataTables that would do `alert('FIRST')` . I'm afraid I couldn't say where that is coming from without being able to access your page.

    Allan
  • allanallan Posts: 61,746Questions: 1Answers: 10,111 Site admin
    Fix committed here: https://github.com/DataTables/DataTablesSrc/commit/d20dec83 . I'll sync the build repo with this fix later on today.

    Allan
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    Thanks a lot Allan. !!
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    HI Allan, Please ignore issue related to the alert(), I guess its problem with my data which is i am getting.
  • VargashVargash Posts: 2Questions: 0Answers: 0

    Did the commit solved your problem?
    Because I think I have the same issue (calling dataTable.ajax.reload();) doesn't make the "loadingRecords" label show in the table in substitution to current data), even if the code snippet committed by Allan is correct, in my source...

  • 7wonders7wonders Posts: 3Questions: 0Answers: 0

    I seem to be experiencing the same problem. I had processing working on 1.9.x but not 1.10.2.

  • 7wonders7wonders Posts: 3Questions: 0Answers: 0

    My bad. It was some bad dom and css on my part.

  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0

    @Vargash I made the changes committed by allan in my datatable library file and it is working fine !!
    I m not sure what does dataTable.ajax.reload() does ??
    if it does same as fnReloadAjax, then things should work .

  • allanallan Posts: 61,746Questions: 1Answers: 10,111 Site admin

    Yes, ajax.reload() is basically the same as the old fnReloadAjax plug-in.

    Allan

  • iFrusciiFrusci Posts: 2Questions: 0Answers: 0

    I'm still experiencing this issue with 1.10.4.

    With ajax.reload(), data is reloaded properly, but the loadingRecords label is definitely not showing up.

  • iFrusciiFrusci Posts: 2Questions: 0Answers: 0

    Ok looks like on ajax.reload it's the processing label that is showing up only.

    So I needed to set bProcessing to true, which makes the processing label appear on reload, however on init I now got both processing label and loadingRecords label, a bit confusing.

  • allanallan Posts: 61,746Questions: 1Answers: 10,111 Site admin

    Fair point. Not thing I'd considered or has been raised before but that is true. I'll consider the best way of handling it.

    Allan

This discussion has been closed.