Skip to content

Commit

Permalink
fix: add abiltiy to copy total row (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
sokumon authored Feb 6, 2025
1 parent ba98142 commit f05049c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/cellmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export default class CellManager {
'columnmanager',
'rowmanager',
'datamanager',
'keyboard'
'keyboard',
'footer'
]);

this.bindEvents();
Expand Down Expand Up @@ -172,6 +173,14 @@ export default class CellManager {
mouseDown = false;
});

if (this.options.showTotalRow) {
$.on(this.footer, 'click', '.dt-cell', (e) => {

this.focusCell($(e.delegatedTarget));
});

}

const selectArea = (e) => {
if (!mouseDown) return;
this.selectArea($(e.delegatedTarget));
Expand Down Expand Up @@ -552,10 +561,18 @@ export default class CellManager {
// copy only focusedCell
const {
colIndex,
rowIndex
rowIndex,
isTotalRow
} = $.data($cell1);
const cell = this.getCell(colIndex, rowIndex);
copyTextToClipboard(cell.content);
let copiedContent = '';
if (isTotalRow) {
let choosenFooterCell = this.$focusedCell;
copiedContent = choosenFooterCell.children[0].title;
} else {
const cell = this.getCell(colIndex, rowIndex);
copiedContent = cell.content;
}
copyTextToClipboard(copiedContent);
return 1;
}
const cells = this.getCellsInRange($cell1, $cell2);
Expand Down Expand Up @@ -754,7 +771,7 @@ export default class CellManager {
}

scrollToCell($cell) {
if ($.inViewport($cell, this.bodyScrollable)) return false;
if ($.inViewport($cell, this.bodyScrollable) || $.inViewport($cell, this.footer)) return false;

const {
rowIndex
Expand Down

0 comments on commit f05049c

Please sign in to comment.