fix checkall behaviour
This commit is contained in:
parent
c8bf326f70
commit
97ce04d8af
@ -1515,9 +1515,14 @@ var DataTable = function () {
|
||||
value: function checkAll(toggle) {
|
||||
var value = toggle ? 1 : 0;
|
||||
|
||||
this.checkMap.map(function (c) {
|
||||
return value;
|
||||
});
|
||||
// update internal map
|
||||
if (toggle) {
|
||||
this.checkMap = Array.from(Array(this.getTotalRows())).map(function (c) {
|
||||
return value;
|
||||
});
|
||||
} else {
|
||||
this.checkMap = [];
|
||||
}
|
||||
// set checkbox value
|
||||
this.bodyScrollable.find('.data-table-col[data-col-index="0"] [type="checkbox"]').prop('checked', toggle);
|
||||
// highlight all
|
||||
@ -1528,7 +1533,7 @@ var DataTable = function () {
|
||||
value: function highlightRow(rowIndex) {
|
||||
var toggle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||
|
||||
var $row = this.bodyScrollable.find('.data-table-row[data-row-index="' + rowIndex + '"]');
|
||||
var $row = this.bodyScrollable.find('.data-table-row[data-row-index="' + rowIndex + '"]:not(.row-highlight)');
|
||||
|
||||
if (toggle) {
|
||||
$row.addClass('row-highlight');
|
||||
@ -1665,6 +1670,11 @@ var DataTable = function () {
|
||||
value: function getCellAttr($cell) {
|
||||
return $cell.data();
|
||||
}
|
||||
}, {
|
||||
key: 'getTotalRows',
|
||||
value: function getTotalRows() {
|
||||
return this.data.rows.length;
|
||||
}
|
||||
}, {
|
||||
key: 'log',
|
||||
value: function log() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -592,7 +592,12 @@ export default class DataTable {
|
||||
checkAll(toggle) {
|
||||
const value = toggle ? 1 : 0;
|
||||
|
||||
this.checkMap.map(c => value);
|
||||
// update internal map
|
||||
if (toggle) {
|
||||
this.checkMap = Array.from(Array(this.getTotalRows())).map(c => value);
|
||||
} else {
|
||||
this.checkMap = [];
|
||||
}
|
||||
// set checkbox value
|
||||
this.bodyScrollable
|
||||
.find('.data-table-col[data-col-index="0"] [type="checkbox"]')
|
||||
@ -602,7 +607,8 @@ export default class DataTable {
|
||||
}
|
||||
|
||||
highlightRow(rowIndex, toggle = true) {
|
||||
const $row = this.bodyScrollable.find(`.data-table-row[data-row-index="${rowIndex}"]`);
|
||||
const $row = this.bodyScrollable
|
||||
.find(`.data-table-row[data-row-index="${rowIndex}"]:not(.row-highlight)`);
|
||||
|
||||
if (toggle) {
|
||||
$row.addClass('row-highlight');
|
||||
@ -723,6 +729,10 @@ export default class DataTable {
|
||||
return $cell.data();
|
||||
}
|
||||
|
||||
getTotalRows() {
|
||||
return this.data.rows.length;
|
||||
}
|
||||
|
||||
log() {
|
||||
if (this.options.enableLogs) {
|
||||
console.log.apply(console, arguments);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user