Skip to content

Commit a42c49d

Browse files
author
dtbuild
committed
f05e12c99d817fded09331e73fcc2e016baea675 Fix: When there is no data in the table, type detection for checkbox columns would fail (requires DataTables 2.1).
Note: Related to this, before DataTables 2.1 if searching and ordering on a DataTable were disabled, type detection would fail. DT2.1 address that. DD-2968 Sync to source repo @f05e12c99d817fded09331e73fcc2e016baea675
1 parent 4119572 commit a42c49d

5 files changed

+41
-13
lines changed

datatables.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
],
1212
"src-repo": "http://github.com/DataTables/Select",
1313
"last-tag": "2.0.3",
14-
"last-sync": "29499007cfe39c2eff6a7fa268d043358b45e41d"
14+
"last-sync": "f05e12c99d817fded09331e73fcc2e016baea675"
1515
}

js/dataTables.select.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -1514,12 +1514,26 @@ $.each(['Row', 'Column', 'Cell'], function (i, item) {
15141514
};
15151515
});
15161516

1517+
// Note that DataTables 2.1 has more robust type detection, but we retain
1518+
// backwards compatbility with 2.0 for the moment.
15171519
DataTable.type('select-checkbox', {
15181520
className: 'dt-select',
1519-
detect: function (data) {
1520-
// Rendering function will tell us if it is a checkbox type
1521-
return data === 'select-checkbox' ? data : false;
1522-
},
1521+
detect: DataTable.versionCheck('2.1')
1522+
? {
1523+
oneOf: function () {
1524+
return false; // no op
1525+
},
1526+
allOf: function () {
1527+
return false; // no op
1528+
},
1529+
init: function (settings, col, idx) {
1530+
return col.mRender && col.mRender.name === 'selectCheckbox';
1531+
}
1532+
}
1533+
: function (data) {
1534+
// Rendering function will tell us if it is a checkbox type
1535+
return data === 'select-checkbox' ? data : false;
1536+
},
15231537
order: {
15241538
pre: function (d) {
15251539
return d === 'X' ? -1 : 0;
@@ -1539,7 +1553,7 @@ DataTable.render.select = function (valueProp, nameProp) {
15391553
var valueFn = valueProp ? DataTable.util.get(valueProp) : null;
15401554
var nameFn = nameProp ? DataTable.util.get(nameProp) : null;
15411555

1542-
return function (data, type, row, meta) {
1556+
return function selectCheckbox(data, type, row, meta) {
15431557
var dtRow = meta.settings.aoData[meta.row];
15441558
var selected = dtRow._select_selected;
15451559
var ariaLabel = meta.settings.oLanguage.select.aria.rowCheckbox;

js/dataTables.select.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dataTables.select.min.mjs

+1-1
Large diffs are not rendered by default.

js/dataTables.select.mjs

+19-5
Original file line numberDiff line numberDiff line change
@@ -1474,12 +1474,26 @@ $.each(['Row', 'Column', 'Cell'], function (i, item) {
14741474
};
14751475
});
14761476

1477+
// Note that DataTables 2.1 has more robust type detection, but we retain
1478+
// backwards compatbility with 2.0 for the moment.
14771479
DataTable.type('select-checkbox', {
14781480
className: 'dt-select',
1479-
detect: function (data) {
1480-
// Rendering function will tell us if it is a checkbox type
1481-
return data === 'select-checkbox' ? data : false;
1482-
},
1481+
detect: DataTable.versionCheck('2.1')
1482+
? {
1483+
oneOf: function () {
1484+
return false; // no op
1485+
},
1486+
allOf: function () {
1487+
return false; // no op
1488+
},
1489+
init: function (settings, col, idx) {
1490+
return col.mRender && col.mRender.name === 'selectCheckbox';
1491+
}
1492+
}
1493+
: function (data) {
1494+
// Rendering function will tell us if it is a checkbox type
1495+
return data === 'select-checkbox' ? data : false;
1496+
},
14831497
order: {
14841498
pre: function (d) {
14851499
return d === 'X' ? -1 : 0;
@@ -1499,7 +1513,7 @@ DataTable.render.select = function (valueProp, nameProp) {
14991513
var valueFn = valueProp ? DataTable.util.get(valueProp) : null;
15001514
var nameFn = nameProp ? DataTable.util.get(nameProp) : null;
15011515

1502-
return function (data, type, row, meta) {
1516+
return function selectCheckbox(data, type, row, meta) {
15031517
var dtRow = meta.settings.aoData[meta.row];
15041518
var selected = dtRow._select_selected;
15051519
var ariaLabel = meta.settings.oLanguage.select.aria.rowCheckbox;

0 commit comments

Comments
 (0)