fix: add abiltiy to copy total row (#204)

This commit is contained in:
Soham Kulkarni 2025-02-06 19:45:03 +05:30 committed by GitHub
parent ba9814228d
commit f05049c67a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,7 +20,8 @@ export default class CellManager {
'columnmanager', 'columnmanager',
'rowmanager', 'rowmanager',
'datamanager', 'datamanager',
'keyboard' 'keyboard',
'footer'
]); ]);
this.bindEvents(); this.bindEvents();
@ -172,6 +173,14 @@ export default class CellManager {
mouseDown = false; mouseDown = false;
}); });
if (this.options.showTotalRow) {
$.on(this.footer, 'click', '.dt-cell', (e) => {
this.focusCell($(e.delegatedTarget));
});
}
const selectArea = (e) => { const selectArea = (e) => {
if (!mouseDown) return; if (!mouseDown) return;
this.selectArea($(e.delegatedTarget)); this.selectArea($(e.delegatedTarget));
@ -552,10 +561,18 @@ export default class CellManager {
// copy only focusedCell // copy only focusedCell
const { const {
colIndex, colIndex,
rowIndex rowIndex,
isTotalRow
} = $.data($cell1); } = $.data($cell1);
let copiedContent = '';
if (isTotalRow) {
let choosenFooterCell = this.$focusedCell;
copiedContent = choosenFooterCell.children[0].title;
} else {
const cell = this.getCell(colIndex, rowIndex); const cell = this.getCell(colIndex, rowIndex);
copyTextToClipboard(cell.content); copiedContent = cell.content;
}
copyTextToClipboard(copiedContent);
return 1; return 1;
} }
const cells = this.getCellsInRange($cell1, $cell2); const cells = this.getCellsInRange($cell1, $cell2);
@ -754,7 +771,7 @@ export default class CellManager {
} }
scrollToCell($cell) { scrollToCell($cell) {
if ($.inViewport($cell, this.bodyScrollable)) return false; if ($.inViewport($cell, this.bodyScrollable) || $.inViewport($cell, this.footer)) return false;
const { const {
rowIndex rowIndex