TX Text Control .NET Server

DocumentTargetCollection Object

Object|Introduced in 28.0

Description

The DocumentTargetCollection contains a collection of targets.

Syntax

DocumentTargetCollection

Examples

The following example demonstrates DocumentTargetCollection in a practical document-editing workflow. The DocumentTargetCollection contains a collection of targets.

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

TXTextControl.textParts.getMainText(function(mainText) {
    const documentTargets = mainText.documentTargets;
    documentTargets.getCanAdd(
        function(result) {
            if (result) {
                console.log("get can add is available.");
            } else {
                console.warn("get can add is not available in the current document state.");
            }
        },
        onTxError
    );
}, onTxError);

Members

Methods

MethodDescription
addAdds a new document target to the collection.
clearRemoves all document targets from the collection.
elementAtReturns the element at a specified index in the collection. (Inherited from Collection.)
forEachExecutes a callback function for each element. (Inherited from Collection.)
getCanAddGets a value indicating whether a new document target can be inserted at the current input position.
getCountGets the number of elements contained in the collection. (Inherited from Collection.)
getItemGets the document target at the current text input position or the document target with the specified id.
removeRemoves the target from the collection.