|
Lines 1-50
Link Here
|
| 1 |
$.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw ) |
|
|
| 2 |
{ |
| 3 |
if ( typeof sNewSource != 'undefined' && sNewSource != null ) |
| 4 |
{ |
| 5 |
oSettings.sAjaxSource = sNewSource; |
| 6 |
} |
| 7 |
this.oApi._fnProcessingDisplay( oSettings, true ); |
| 8 |
var that = this; |
| 9 |
var iStart = oSettings._iDisplayStart; |
| 10 |
var aData = []; |
| 11 |
|
| 12 |
this.oApi._fnServerParams( oSettings, aData ); |
| 13 |
|
| 14 |
oSettings.fnServerData( oSettings.sAjaxSource, aData, function(json) { |
| 15 |
/* Clear the old information from the table */ |
| 16 |
that.oApi._fnClearTable( oSettings ); |
| 17 |
|
| 18 |
/* Got the data - add it to the table */ |
| 19 |
var aData = (oSettings.sAjaxDataProp !== "") ? |
| 20 |
that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json; |
| 21 |
|
| 22 |
for ( var i=0 ; i<aData.length ; i++ ) |
| 23 |
{ |
| 24 |
that.oApi._fnAddData( oSettings, aData[i] ); |
| 25 |
} |
| 26 |
|
| 27 |
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); |
| 28 |
that.fnDraw(); |
| 29 |
|
| 30 |
if ( typeof bStandingRedraw != 'undefined' && bStandingRedraw === true ) |
| 31 |
{ |
| 32 |
oSettings._iDisplayStart = iStart; |
| 33 |
that.fnDraw( false ); |
| 34 |
} |
| 35 |
|
| 36 |
that.oApi._fnProcessingDisplay( oSettings, false ); |
| 37 |
|
| 38 |
/* Callback user function - for event handlers etc */ |
| 39 |
if ( typeof fnCallback == 'function' && fnCallback != null ) |
| 40 |
{ |
| 41 |
fnCallback( oSettings ); |
| 42 |
} |
| 43 |
}, oSettings ); |
| 44 |
} |
| 45 |
|
| 46 |
/* Example call to load a new file */ |
| 47 |
//oTable.fnReloadAjax( 'media/examples_support/json_source2.txt' ); |
| 48 |
|
| 49 |
/* Example call to reload from original file */ |
| 50 |
//oTable.fnReloadAjax(); |
| 51 |
- |