mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-30 23:52:11 +01:00
Updated - server-side processing support for camelCase variables
- As part of the 1.10 move to camelCase the server-side processing return now accepts camelCase variables as well as the old 1.9 hungarian notation.
This commit is contained in:
parent
a70f109ac4
commit
c9c8e65708
@ -1 +1 @@
|
|||||||
713a7bae8fa1534efa193f133066c822ce61bfbc
|
46f173ffbefa21ff9e1a51995e9b0da1345b72fd
|
||||||
|
57
media/js/jquery.dataTables.js
vendored
57
media/js/jquery.dataTables.js
vendored
@ -2156,8 +2156,9 @@
|
|||||||
var baseAjax = {
|
var baseAjax = {
|
||||||
"data": data,
|
"data": data,
|
||||||
"success": function (json) {
|
"success": function (json) {
|
||||||
if ( json.sError ) {
|
var error = json.error || json.sError;
|
||||||
oSettings.oApi._fnLog( oSettings, 0, json.sError );
|
if ( error ) {
|
||||||
|
oSettings.oApi._fnLog( oSettings, 0, error );
|
||||||
}
|
}
|
||||||
|
|
||||||
oSettings.json = json;
|
oSettings.json = json;
|
||||||
@ -2341,41 +2342,45 @@
|
|||||||
* @param {string} [json.sColumns] Column ordering (sName, comma separated)
|
* @param {string} [json.sColumns] Column ordering (sName, comma separated)
|
||||||
* @memberof DataTable#oApi
|
* @memberof DataTable#oApi
|
||||||
*/
|
*/
|
||||||
function _fnAjaxUpdateDraw ( oSettings, json )
|
function _fnAjaxUpdateDraw ( settings, json )
|
||||||
{
|
{
|
||||||
if ( json.sEcho !== undefined )
|
// v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
|
||||||
{
|
// Support both
|
||||||
/* Protect against old returns over-writing a new one. Possible when you get
|
var compat = function ( old, modern ) {
|
||||||
* very fast interaction, and later queries are completed much faster
|
return json[old] !== undefined ? json[old] : json[modern];
|
||||||
*/
|
};
|
||||||
if ( json.sEcho*1 < oSettings.iDraw )
|
|
||||||
{
|
var draw = compat( 'sEcho', 'draw' );
|
||||||
|
var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
|
||||||
|
var rocordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
|
||||||
|
|
||||||
|
if ( draw ) {
|
||||||
|
// Protect against out of sequence returns
|
||||||
|
if ( draw*1 < settings.iDraw ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oSettings.iDraw = json.sEcho * 1;
|
settings.iDraw = draw * 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_fnClearTable( oSettings );
|
_fnClearTable( settings );
|
||||||
oSettings._iRecordsTotal = parseInt(json.iTotalRecords, 10);
|
settings._iRecordsTotal = parseInt(recordsTotal, 10);
|
||||||
oSettings._iRecordsDisplay = parseInt(json.iTotalDisplayRecords, 10);
|
settings._iRecordsDisplay = parseInt(rocordsFiltered, 10);
|
||||||
|
|
||||||
var aData = _fnAjaxDataSrc( oSettings, json );
|
var data = _fnAjaxDataSrc( settings, json );
|
||||||
for ( var i=0, iLen=aData.length ; i<iLen ; i++ )
|
for ( var i=0, ien=data.length ; i<ien ; i++ ) {
|
||||||
{
|
_fnAddData( settings, data[i] );
|
||||||
_fnAddData( oSettings, aData[i] );
|
|
||||||
}
|
}
|
||||||
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
|
settings.aiDisplay = settings.aiDisplayMaster.slice();
|
||||||
|
|
||||||
oSettings.bAjaxDataGet = false;
|
settings.bAjaxDataGet = false;
|
||||||
_fnDraw( oSettings );
|
_fnDraw( settings );
|
||||||
|
|
||||||
if ( ! oSettings._bInitComplete )
|
if ( ! settings._bInitComplete ) {
|
||||||
{
|
_fnInitComplete( settings, json );
|
||||||
_fnInitComplete( oSettings, json );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oSettings.bAjaxDataGet = true;
|
settings.bAjaxDataGet = true;
|
||||||
_fnProcessingDisplay( oSettings, false );
|
_fnProcessingDisplay( settings, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user