DS Server

Javascript: Table.getOuterMostTable Method

Method|Introduced in 28.0

Description

Gets a table's outermost table. This is a top-level table with a nested level of 1. The property's value is an object of the prototype Table or null if this table is already a top-level table.

Syntax

<void> Table.getOuterMostTable(<RequestTableCallback> callback, [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
callback

Receives the outer most table as parameter.

errorCallback

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

Examples

The following example demonstrates Table.getOuterMostTable in a practical document-editing workflow. It gets a table's outermost table. This is a top-level table with a nested level of 1. The property's value is an object of the prototype Table or null if this table is already a top-level table.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const tables = mainText.tables;
    tables.getItem(function(table) {
        if (!table) {
            console.warn("No table is available at the current input position.");
            return;
        }
    
        table.getOuterMostTable(
            function(table) {
                if (!table) {
                    console.warn("No table was returned.");
                    return;
                }
                
                console.log("get outer most table result:", table);
            },
            onTxError
        );
    }, onTxError);
}, onTxError);