DS Server

Javascript: TableCell.setFormula Method

Method|Introduced in 28.0

Description

Sets the table cell's formula. For each table cell a formula can be defined which is used to calculate the cell's text. The formula can contain references to other table cells in the same table. When the text of a referenced cell changes, the cell which references it is automatically updated.

Syntax

<void> TableCell.setFormula(<string> formula, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
formula

The cell's formula.

callback

Optional. Is called when the operation completed.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates TableCell.setFormula in a practical document-editing workflow. It sets the table cell's formula. For each table cell a formula can be defined which is used to calculate the cell's text. The formula can contain references to other table cells in the same table. When the text of a referenced cell changes, the cell which references it is automatically updated.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

function configureFormula(tableCell) {
    tableCell.setFormula(
        "Quarterly report",
        function() {
            console.log("set formula completed.");
        },
        onTxError
    );
}