Skip to content

Commit

Permalink
c91e8f4cfa9a1551c4eb5dd6b5325e60a6203e32 Fix: Correctly handle a colu…
Browse files Browse the repository at this point in the history
…mn type of `null`, which is the case for server-side processing columns in DataTables 2.1, unless explicity given

DD-2991

Sync to source repo @c91e8f4cfa9a1551c4eb5dd6b5325e60a6203e32
  • Loading branch information
dtbuild committed Jul 24, 2024
1 parent e4687a2 commit 42dfff4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
],
"src-repo": "http://github.com/DataTables/SearchBuilder",
"last-tag": "1.7.1",
"last-sync": "2e9f351b571cd8c197ebe27d943949c33780d20b"
"last-sync": "c91e8f4cfa9a1551c4eb5dd6b5325e60a6203e32"
}
13 changes: 7 additions & 6 deletions js/dataTables.searchBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ var DataTable = $.fn.dataTable;
if (this.s.condition !== undefined && condition !== undefined) {
var filter = rowData[this.s.dataIdx];
// This check is in place for if a custom decimal character is in place
if (this.s.type.includes('num') &&
if (this.s.type &&
this.s.type.includes('num') &&
(settings.oLanguage.sDecimal !== '' ||
settings.oLanguage.sThousands !== '')) {
var splitRD = [rowData[this.s.dataIdx]];
Expand Down Expand Up @@ -379,7 +380,7 @@ var DataTable = $.fn.dataTable;
}
}
}
if (this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
if (this.s.type && this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
for (i = 0; i < this.s.value.length; i++) {
this.s.value[i] = this.s.value[i].replace(/[^0-9.\-]/g, '');
}
Expand Down Expand Up @@ -738,7 +739,7 @@ var DataTable = $.fn.dataTable;
.prop('selected', true);
var decimal = dt.settings()[0].oLanguage.sDecimal;
// This check is in place for if a custom decimal character is in place
if (decimal !== '' && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
if (decimal !== '' && this.s.type && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
if (this.s.type.includes('num-fmt')) {
this.s.type = this.s.type.replace(decimal, '');
}
Expand All @@ -751,19 +752,19 @@ var DataTable = $.fn.dataTable;
if (this.c.conditions[this.s.type] !== undefined) {
conditionObj = this.c.conditions[this.s.type];
}
else if (this.s.type.includes('datetime-')) {
else if (this.s.type && this.s.type.includes('datetime-')) {
// Date / time data types in DataTables are driven by Luxon or
// Moment.js.
conditionObj = DataTable.use('moment')
? this.c.conditions.moment
: this.c.conditions.luxon;
this.s.dateFormat = this.s.type.replace(/datetime-/g, '');
}
else if (this.s.type.includes('moment')) {
else if (this.s.type && this.s.type.includes('moment')) {
conditionObj = this.c.conditions.moment;
this.s.dateFormat = this.s.type.replace(/moment-/g, '');
}
else if (this.s.type.includes('luxon')) {
else if (this.s.type && this.s.type.includes('luxon')) {
conditionObj = this.c.conditions.luxon;
this.s.dateFormat = this.s.type.replace(/luxon-/g, '');
}
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.searchBuilder.min.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions js/dataTables.searchBuilder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ let $ = jQuery;
if (this.s.condition !== undefined && condition !== undefined) {
var filter = rowData[this.s.dataIdx];
// This check is in place for if a custom decimal character is in place
if (this.s.type.includes('num') &&
if (this.s.type &&
this.s.type.includes('num') &&
(settings.oLanguage.sDecimal !== '' ||
settings.oLanguage.sThousands !== '')) {
var splitRD = [rowData[this.s.dataIdx]];
Expand Down Expand Up @@ -339,7 +340,7 @@ let $ = jQuery;
}
}
}
if (this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
if (this.s.type && this.s.type.includes('num') && this.s.dt.page.info().serverSide) {
for (i = 0; i < this.s.value.length; i++) {
this.s.value[i] = this.s.value[i].replace(/[^0-9.\-]/g, '');
}
Expand Down Expand Up @@ -698,7 +699,7 @@ let $ = jQuery;
.prop('selected', true);
var decimal = dt.settings()[0].oLanguage.sDecimal;
// This check is in place for if a custom decimal character is in place
if (decimal !== '' && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
if (decimal !== '' && this.s.type && this.s.type.indexOf(decimal) === this.s.type.length - decimal.length) {
if (this.s.type.includes('num-fmt')) {
this.s.type = this.s.type.replace(decimal, '');
}
Expand All @@ -711,19 +712,19 @@ let $ = jQuery;
if (this.c.conditions[this.s.type] !== undefined) {
conditionObj = this.c.conditions[this.s.type];
}
else if (this.s.type.includes('datetime-')) {
else if (this.s.type && this.s.type.includes('datetime-')) {
// Date / time data types in DataTables are driven by Luxon or
// Moment.js.
conditionObj = DataTable.use('moment')
? this.c.conditions.moment
: this.c.conditions.luxon;
this.s.dateFormat = this.s.type.replace(/datetime-/g, '');
}
else if (this.s.type.includes('moment')) {
else if (this.s.type && this.s.type.includes('moment')) {
conditionObj = this.c.conditions.moment;
this.s.dateFormat = this.s.type.replace(/moment-/g, '');
}
else if (this.s.type.includes('luxon')) {
else if (this.s.type && this.s.type.includes('luxon')) {
conditionObj = this.c.conditions.luxon;
this.s.dateFormat = this.s.type.replace(/luxon-/g, '');
}
Expand Down

0 comments on commit 42dfff4

Please sign in to comment.