Show spinner when we call fnReloadAjax function and unnecessary alerts
Show spinner when we call fnReloadAjax function and unnecessary alerts
raul_lfc
Posts: 21Questions: 1Answers: 0
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
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
This discussion has been closed.
Replies
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
Allan
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...
I seem to be experiencing the same problem. I had processing working on 1.9.x but not 1.10.2.
My bad. It was some bad dom and css on my part.
@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 .
Yes,
ajax.reload()
is basically the same as the old fnReloadAjax plug-in.Allan
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.
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.
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