Skip to content

Commit

Permalink
214b2af45d882f6cc7711cbec0b63c2a6e43cdaf Fix: When the header checkbo…
Browse files Browse the repository at this point in the history
…x is in `select-page` mode, it will now correctly reflect the status of the current page and operate only on the current page.

DD-2979

a99e51b6f140c9351e381bc35ad98def223a7929 Select 2.1.0

Sync to source repo @a99e51b6f140c9351e381bc35ad98def223a7929
  • Loading branch information
dtbuild committed Sep 12, 2024
1 parent a7cc04b commit 764857b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 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/Select",
"last-tag": "2.0.5",
"last-sync": "0c65c57b3a55641b557a2d260dc1fa70f16f6a7e"
"last-sync": "a99e51b6f140c9351e381bc35ad98def223a7929"
}
22 changes: 15 additions & 7 deletions js/dataTables.select.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Select for DataTables 2.0.5
/*! Select for DataTables 2.1.0
* © SpryMedia Ltd - datatables.net/license/mit
*/

Expand Down Expand Up @@ -56,7 +56,7 @@ DataTable.select.classes = {
checkbox: 'dt-select-checkbox'
};

DataTable.select.version = '2.0.5';
DataTable.select.version = '2.1.0';

DataTable.select.init = function (dt) {
var ctx = dt.settings()[0];
Expand Down Expand Up @@ -651,13 +651,18 @@ function initCheckboxHeader( dt, headerCheckbox ) {
}
}
else {
dt.rows({selected: true}).deselect();
if (headerCheckbox == 'select-page') {
dt.rows({page: 'current', selected: true}).deselect();
}
else {
dt.rows({selected: true}).deselect();
}
}
})
.on('click', function (e) {
e.stopPropagation();
});

// Update the header checkbox's state when the selection in the
// table changes
dt.on('draw select deselect', function (e, pass, type) {
Expand Down Expand Up @@ -695,9 +700,13 @@ function initCheckboxHeader( dt, headerCheckbox ) {
function headerCheckboxState(dt, headerCheckbox) {
var ctx = dt.settings()[0];
var selectable = ctx._select.selectable;
var count = dt.rows({selected: true}).count()
var search = dt.rows({search: 'applied', selected: true}).count();
var available = 0;
var count = headerCheckbox == 'select-page'
? dt.rows({page: 'current', selected: true}).count()
: dt.rows({selected: true}).count();
var search = headerCheckbox == 'select-page'
? dt.rows({page: 'current', selected: true}).count()
: dt.rows({search: 'applied', selected: true}).count();

if (! selectable) {
available = headerCheckbox == 'select-page'
Expand Down Expand Up @@ -1156,7 +1165,6 @@ apiRegister('select.style()', function (style) {
// API selection is available
var dt = new DataTable.Api(ctx);

console.log('style', style);
if (style !== 'api') {
dt.ready(function () {
disableMouseSelection(dt);
Expand Down
4 changes: 2 additions & 2 deletions js/dataTables.select.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 764857b

Please sign in to comment.