Disabling cell selection on chosen cells

Tags: #<Tag:0x00007efc7098e798>

Hi,

I am refering to this question: Disable cell selection

We would like to be able to disable the selection only for some cells.

It looks like Handsontable.GridSettings.disableVisualSelection is working as expected, but Handsontable.CellProperties.disableVisualSelection has no effect. We are using the Angular wrapper like this:

const gridSettings: HandsonTable.GridSettings = {
   ....
       cells: (row, col) => {
            const cellProperties: Handsontable.CellMeta = {
                   disableVisualSelection : ['current', 'area']; // this has no efect
            };
            return cellProperties;
       }
}

Is this normal that this has no effect ?

Thank you for your help and best regards,

Vincent

Hey Vincent,

It is not documented but I can see it works well https://jsfiddle.net/abmjsvt2/

I’ve used the beforeOnCellMouseDown to check target’s innerText. It would be harder to get coordinates so I hope that tracking a value work for you.

Hi Alexandra,

Thank you for your quick answer.

Actually your solution will certainly prevent a cell click event listener to be triggered. Actually I want to disable the selection of the cell but still allow to click on it…

What looks strange to me is that the CellProperties interfaceoffers (IDE auto-complete) the disableVisualSelection toggle…

After looking further into the types declaration, it looks like this comes from some weird interface extention in the types definitions:

interface ColumnSettings extends Omit<GridSettings, "data"> {
    data?: string | number | ColumnDataGetterSetterFunction;
    /**
     * Column and cell meta data is extensible, developers can add any properties they want.
     */
    [key: string]: any;
  }

This says “takes everything from the GridSettings but data”. So there must be properties that while accepted are not implemented… I guess this is the case for disableVisualSelection which I guess is not implemented at the cell level…

Does this analysis makes any sens to you?

Best Regards,

Vincent

That is true. Those settings are table-oriented.

What is this click used for? Do you want to open the editor?

No, We would like to hide/show some rows when clicking on that cell. We made the cell readonly which is already good, but there is no interest for us in selecting the cell (the user will click on it only to trigger the afterOnCellMouseDown event)

Maybe we could use your hack in the beforeOnCellMouseDown and move our listeners there…

That sounds like a good plan.