Skip to content

Commit

Permalink
369001c7868ab47693b85bc0a42df1de18711c59 Fix: Server-side processing …
Browse files Browse the repository at this point in the history
…auto type detection is enabled again (was removed in 2.1.0). It will attempt column type detection immediately, which was a large part of the issue before, in that the column type would not be detected until a user requested a column type (e.g. for SearchBuilder).

New: Auto column type detection can now be disabled with the new `-init detectType` option.

Sync to source repo @369001c7868ab47693b85bc0a42df1de18711c59
  • Loading branch information
dtbuild committed Sep 2, 2024
1 parent 82b7af4 commit 4b0c6e0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "2.1.5",
"last-sync": "d8c8900fbafa42a90aec216397ebf13095c10a20"
"last-sync": "369001c7868ab47693b85bc0a42df1de18711c59"
}
19 changes: 12 additions & 7 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
"caption",
"layout",
"orderDescReverse",
"typeDetect",
[ "iCookieDuration", "iStateDuration" ], // backwards compat
[ "oSearch", "oPreviousSearch" ],
[ "aoSearchCols", "aoPreSearchCols" ],
Expand Down Expand Up @@ -2274,12 +2275,6 @@
var i, ien, j, jen, k, ken;
var col, detectedType, cache;

// If SSP then we don't have the full data set, so any type detection would be
// unreliable and error prone
if (_fnDataSource( settings ) === 'ssp') {
return;
}

// For each column, spin over the data type detection functions, seeing if one matches
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
col = columns[i];
Expand All @@ -2289,6 +2284,12 @@
col.sType = col._sManualType;
}
else if ( ! col.sType ) {
// With SSP type detection can be unreliable and error prone, so we provide a way
// to turn it off.
if (! settings.typeDetect) {
return;
}

for ( j=0, jen=types.length ; j<jen ; j++ ) {
var typeDetect = types[j];

Expand Down Expand Up @@ -4340,6 +4341,7 @@
}
settings.aiDisplay = settings.aiDisplayMaster.slice();

_fnColumnTypes(settings);
_fnDraw( settings, true );
_fnInitComplete( settings );
_fnProcessingDisplay( settings, false );
Expand Down Expand Up @@ -11960,7 +11962,10 @@
colgroup: null,

/** Delay loading of data */
deferLoading: null
deferLoading: null,

/** Allow auto type detection */
typeDetect: true
};

/**
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.min.mjs

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ var DataTable = function ( selector, options )
"caption",
"layout",
"orderDescReverse",
"typeDetect",
[ "iCookieDuration", "iStateDuration" ], // backwards compat
[ "oSearch", "oPreviousSearch" ],
[ "aoSearchCols", "aoPreSearchCols" ],
Expand Down Expand Up @@ -2221,12 +2222,6 @@ function _fnColumnTypes ( settings )
var i, ien, j, jen, k, ken;
var col, detectedType, cache;

// If SSP then we don't have the full data set, so any type detection would be
// unreliable and error prone
if (_fnDataSource( settings ) === 'ssp') {
return;
}

// For each column, spin over the data type detection functions, seeing if one matches
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
col = columns[i];
Expand All @@ -2236,6 +2231,12 @@ function _fnColumnTypes ( settings )
col.sType = col._sManualType;
}
else if ( ! col.sType ) {
// With SSP type detection can be unreliable and error prone, so we provide a way
// to turn it off.
if (! settings.typeDetect) {
return;
}

for ( j=0, jen=types.length ; j<jen ; j++ ) {
var typeDetect = types[j];

Expand Down Expand Up @@ -4287,6 +4288,7 @@ function _fnAjaxUpdateDraw ( settings, json )
}
settings.aiDisplay = settings.aiDisplayMaster.slice();

_fnColumnTypes(settings);
_fnDraw( settings, true );
_fnInitComplete( settings );
_fnProcessingDisplay( settings, false );
Expand Down Expand Up @@ -11907,7 +11909,10 @@ DataTable.models.oSettings = {
colgroup: null,

/** Delay loading of data */
deferLoading: null
deferLoading: null,

/** Allow auto type detection */
typeDetect: true
};

/**
Expand Down

0 comments on commit 4b0c6e0

Please sign in to comment.