Skip to content

Commit f05049c

Browse files
authored
fix: add abiltiy to copy total row (#204)
1 parent ba98142 commit f05049c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/cellmanager.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default class CellManager {
2020
'columnmanager',
2121
'rowmanager',
2222
'datamanager',
23-
'keyboard'
23+
'keyboard',
24+
'footer'
2425
]);
2526

2627
this.bindEvents();
@@ -172,6 +173,14 @@ export default class CellManager {
172173
mouseDown = false;
173174
});
174175

176+
if (this.options.showTotalRow) {
177+
$.on(this.footer, 'click', '.dt-cell', (e) => {
178+
179+
this.focusCell($(e.delegatedTarget));
180+
});
181+
182+
}
183+
175184
const selectArea = (e) => {
176185
if (!mouseDown) return;
177186
this.selectArea($(e.delegatedTarget));
@@ -552,10 +561,18 @@ export default class CellManager {
552561
// copy only focusedCell
553562
const {
554563
colIndex,
555-
rowIndex
564+
rowIndex,
565+
isTotalRow
556566
} = $.data($cell1);
557-
const cell = this.getCell(colIndex, rowIndex);
558-
copyTextToClipboard(cell.content);
567+
let copiedContent = '';
568+
if (isTotalRow) {
569+
let choosenFooterCell = this.$focusedCell;
570+
copiedContent = choosenFooterCell.children[0].title;
571+
} else {
572+
const cell = this.getCell(colIndex, rowIndex);
573+
copiedContent = cell.content;
574+
}
575+
copyTextToClipboard(copiedContent);
559576
return 1;
560577
}
561578
const cells = this.getCellsInRange($cell1, $cell2);
@@ -754,7 +771,7 @@ export default class CellManager {
754771
}
755772

756773
scrollToCell($cell) {
757-
if ($.inViewport($cell, this.bodyScrollable)) return false;
774+
if ($.inViewport($cell, this.bodyScrollable) || $.inViewport($cell, this.footer)) return false;
758775

759776
const {
760777
rowIndex

0 commit comments

Comments
 (0)