1
votes

I use Handsontable and in one column, the data type is an integer that is an index of a vector of strings v. So, instead of showing the integer index i, I have to show v[i]. I do so by declaring a custom renderer in handsontable:

var annotationTableSettings = {
        data: componentAnnotation,
        columns: [
            {renderer: annotationId2StringRenderer},
             ...

However, when I copy the value of the cell (Ctrl+c in windows/linux or cmd+c in mac), the integer is copied instead of the rendered value. Does anyone know how to copy the rendered value (I would like to keep the integer data type and the custom renderer).

An example can be seen here: http://leoisl.gitlab.io/DBGWAS_support/full_dataset_visualization_0_4_6/components/comp_2.html Just copy the first cell of the first line of the first table (in the north panel) - the cell with value "(Phe)CML" and you will copy the value 3, instead of "(Phe)CML" itself.

Thanks in advance!

1

1 Answers

1
votes

you can use the beforeCopy hook.

var annotationTableSettings = {
    data: componentAnnotation,
    beforeCopy: data => {
        for (let i = 0; i < data.length; i++) {
            for (let j = 0; j < data[i].length; j++) {
                if (!isNaN(data[i][j])) {
                    data[i][j] = v[data[i][j]]
                }
            }
        }
    }
    columns: [
        {renderer: annotationId2StringRenderer},
        ...