DS Server

Collection Object

Object|Introduced in 28.0

Description

Provides methods for accessing collections.

Syntax

Collection

Examples

The following example shows how to retrieve all application fields from the document's main text and do something with them afterwards:

let fields = [];
TXTextControl.applicationFields.forEach((field, i, n) => {
   fields.push(field);
   if (i == (n - 1)) {
      console.log(`${fields.length} application fields retrieved!`);
      // Do something meaningful with the retrieved fields here...
   }
});


Possible console output after calling this code:

> 17 application fields retrieved!

The following example demonstrates Collection in a practical document-editing workflow. It provides methods for accessing collections.

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

function inspectCollection(s) {
    s.getCount(
        function(result) {
            console.log("get count result:", result);
        },
        onTxError
    );
}

Members

Methods

MethodDescription
elementAtReturns the element at a specified index in the collection.
forEachExecutes a callback function for each element.
getCountGets the number of elements contained in the collection.