Skip to content

Handsontable module usage

Create a new empty label widget in a GUI and give it a unique id, like myTable. Then create a new R file and add it to the sequencer before the GUI containing the table. In the R file, source the module:

source(rpgm.pgmFilePath('modules/handsontable/main.R'))

You can then initialize the table. This must be done before entering the GUI with the table.

Handsontable.create(
    'main',
    rpgm.step('main', 'handsontable'),
    'myTable',
    height = 512,
    # Options are the Handsontable options, see https://handsontable.com/docs/javascript-data-grid/api/options/
    options = list(
        data=mtcars,
        rowHeaders=TRUE,
        colHeaders=TRUE,

        autoColumnSize=TRUE,
        columnSorting=TRUE,
        manualColumnResize=TRUE,

        rowHeaderWidth=50,
        colWidths=c(100, 150, 100, 100, 100, 100, 50, 50, 50, 50),
        width='100%',
        stretchH='all',

        autoWrapRow=TRUE,
        autoWrapCol=TRUE,

        filters=TRUE,
        dropdownMenu=TRUE,

        licenseKey='non-commercial-and-evaluation' # You should enter your commercial license key here.
    )
);

See the Handsontable.create() section for more information on the parameters. The options parameter is the Handonstable options object, converted to list. You can find all options in the official documentation of Handsontable here. When calling function for modifying the table, always use the myTable id for the tableId parameter in functions. You can setup event listener to change the behaviour of the table depending on the user's inputs (see Events).