DS Server

Javascript: Table.getCanMergeCells Method

Method|Introduced in 28.0

Description

Checks whether table cells can be merged. Table cells can only be merged, if more than one cell in this table is selected.

Syntax

<void> Table.getCanMergeCells(<RequestBooleanCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives whether the selected cells can be merged.

errorCallback

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

Examples

The following example checks the selected cell range before merging it, so the action is attempted only in a valid table state.

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

TXTextControl.textParts.getMainText(function(mainText) {
    mainText.tables.getItem(function(table) {
        if (!table) {
            console.warn("Place the input position in a table.");
            return;
        }

        table.getCanMergeCells(function(canMerge) {
            if (!canMerge) {
                console.warn("Select at least two adjacent table cells.");
                return;
            }

            table.mergeCells(function(merged) {
                console.log("Selected cells merged:", merged);
            }, onTxError);
        }, onTxError);
    }, onTxError);
}, onTxError);