Posted 18 March 2024, 9:24 am EST
Hi,
You can handle the copying event on Flexgrid, to execute your custom copy function, You can achieve that by using Wijmo’s clipboard. Please refer to the code snippet and sample link below for reference:
theGrid.copying.addHandler((s, e) => {
//cancel default behavior
e.cancel = true;
var copyString = '',
newLine = '',
tab = '';
for (var r = e.range.topRow; r <= e.range.bottomRow; r++) {
if (s.rows[r].visible) {
for (var c = e.range.leftCol; c <= e.range.rightCol; c++) {
var col = s.columns[c];
if (col.visible) {
newLine = c == e.range.rightCol ? '\n' : '';
tab = c == e.range.rightCol ? '' : '\t';
//get selected cell data
var selectedCellData = s.getCellData(r, c);
selectedCellData =
selectedCellData == null || undefined ? '' : selectedCellData;
if (col.binding === 'change') {
selectedCellData = e.panel.getCellElement(r, c).innerText;
}
copyString += selectedCellData + tab + newLine;
}
}
//copy data into Clipboard
wijmo.Clipboard.copy(copyString);
}
}
});
sample link: https://stackblitz.com/edit/js-cympzz?file=index.js
You can modify the copy logic as per your requirements. In case you need further assistance then please let us know.
Regards