Copy and paste displayed value of a custom rendered cell

Tags: #<Tag:0x00007f8b1df59d08>

Hi,

I have trouble copying the value displayed is a cell using a custom renderer.
This cell is used to display the result of a calculation based on the values of other cells in the table.
I want the user to be able to copy this displayed value and paste it in another cell.
However, it is pasting an empty string.

As far as I understand, it is because I don’t update the grid’s data with the calculated value.

I tried to call the method setDataAtCell in the code of my custom renderer, but it is causing a severe decrease of performance.

td.innerHTML = calculatedValue; // to display the result
hotInstance.setDataAtCell(row, column, calculatedValue);

I also tried to look into the beforeCopy hook, but the data passed to this hook is empty.

So my question is, if my reasoning is correct, is there a way to copy the displayed value instead of the cell’s data ?

Hi @baptiste.boullay

Without a demo, can be hard to find a solution.

May I send to you demo - https://codesandbox.io/s/custom-renderer-map-image-date-example-mwq6h
And you based on it extend to better reflect your needs and your issue.

Let me know if you need anything else.

Hi Piotr,

Based on this answer : How to set the value at the cell without change the source value at the cell?
I changed the way my calculation is done. It is now done via the “modifyData” hook, instead of a renderer. This allows me to copy the result of the calculation.
However, the calculation is much longer than with the renderer, but I guess it is because I modify table’s data instead of just modifying the rendered data.

I will modify your link to give you an example.

do we have any progress here?

I’m closing the topic as we do not have any new updates here.