MCPcopy Create free account
hub / github.com/blockstrap/framework / _fnAjaxUpdateDraw

Function _fnAjaxUpdateDraw

blockstrap/js/dependencies/tables.js:2549–2588  ·  view source on GitHub ↗

* Data the data from the server (nuking the old) and redraw the table * @param {object} oSettings dataTables settings object * @param {object} json json data return from the server. * @param {string} json.sEcho Tracking flag for DataTables to match requests * @param {int} json.iTotalReco

( settings, json )

Source from the content-addressed store, hash-verified

2547 * @memberof DataTable#oApi
2548 */
2549 function _fnAjaxUpdateDraw ( settings, json )
2550 {
2551 // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
2552 // Support both
2553 var compat = function ( old, modern ) {
2554 return json[old] !== undefined ? json[old] : json[modern];
2555 };
2556
2557 var draw = compat( 'sEcho', 'draw' );
2558 var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
2559 var rocordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
2560
2561 if ( draw ) {
2562 // Protect against out of sequence returns
2563 if ( draw*1 < settings.iDraw ) {
2564 return;
2565 }
2566 settings.iDraw = draw * 1;
2567 }
2568
2569 _fnClearTable( settings );
2570 settings._iRecordsTotal = parseInt(recordsTotal, 10);
2571 settings._iRecordsDisplay = parseInt(rocordsFiltered, 10);
2572
2573 var data = _fnAjaxDataSrc( settings, json );
2574 for ( var i=0, ien=data.length ; i<ien ; i++ ) {
2575 _fnAddData( settings, data[i] );
2576 }
2577 settings.aiDisplay = settings.aiDisplayMaster.slice();
2578
2579 settings.bAjaxDataGet = false;
2580 _fnDraw( settings );
2581
2582 if ( ! settings._bInitComplete ) {
2583 _fnInitComplete( settings, json );
2584 }
2585
2586 settings.bAjaxDataGet = true;
2587 _fnProcessingDisplay( settings, false );
2588 }
2589
2590
2591 /**

Callers 1

_fnAjaxUpdateFunction · 0.85

Calls 7

compatFunction · 0.85
_fnClearTableFunction · 0.85
_fnAjaxDataSrcFunction · 0.85
_fnAddDataFunction · 0.85
_fnDrawFunction · 0.85
_fnInitCompleteFunction · 0.85
_fnProcessingDisplayFunction · 0.85

Tested by

no test coverage detected