How to use ColumnDataGetterSetterFunction

Tags: #<Tag:0x00007efc706b6048>

I am having issues using the ColumnDataGetterSetterFunction to get/set data for some column.

In the source code I see that data in ColumnSettings can be of type ColumnDataGetterSetterFunction.

export 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;
}

The interface definition I see is

export interface ColumnDataGetterSetterFunction {
  (row: RowObject | CellValue[]): CellValue;
  (row: RowObject | CellValue[], value: CellValue): void;
}

My understanding is that this ?function/not sure what? that implements this interface would be responsible to get/set data for the cells in the column.

To be honest I cannot fully grasp this interface and cannot really find any explanation in the Typescript documentation how such interfaces work, that define two anonymous signatures.

My question is how this interface should be used correctly?

I tried to make it work in this Stackblitz but the column for which I return such a function simply is not shown.
Stackblitz

Hi @frigo

This is our internal interface which is not supposed to be used by the end users. You can find all available data binding methods in our documentation, but as far as I can see, you want to use a function so this part might be helpful:

https://handsontable.com/docs/javascript-data-grid/binding-to-data/#array-of-objects-with-column-as-a-function