From d61f2dcca5ecbea4dc827f36b3ab4a44284c8e79 Mon Sep 17 00:00:00 2001 From: sokumon Date: Thu, 6 Feb 2025 19:42:29 +0530 Subject: [PATCH] fix: add abiltiy to copy total row --- src/cellmanager.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/cellmanager.js b/src/cellmanager.js index 83b1781..c1d1a8f 100644 --- a/src/cellmanager.js +++ b/src/cellmanager.js @@ -20,7 +20,8 @@ export default class CellManager { 'columnmanager', 'rowmanager', 'datamanager', - 'keyboard' + 'keyboard', + 'footer' ]); this.bindEvents(); @@ -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)); @@ -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); @@ -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