DS Server

Javascript: TableCollection.getItem Method

Method|Introduced in 28.0

Description

Gets the table at the current input position or the first table in the collection with the given id.

Syntax

<void> TableCollection.getItem(<RequestTableCallback> callback, [<ErrorCallback> errorCallback], [<number> id])

Parameters

ParameterDescription
callback

Receives the requested table or null if there is no table at the current input position / with the requested id.

errorCallback

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

id

Optional. The table's identifier.

Examples

The following example demonstrates TableCollection.getItem in a practical document-editing workflow. It gets the table at the current input position or the first table in the collection with the given id.

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 was returned.");
                return;
            }
            
            console.log("get item result:", table);
        },
        onTxError,
        25
    );
}, onTxError);