DS Server

Javascript: SelectionFormField.setSelectedIndex Method

Method|Introduced in 28.0

Description

Sets the index of the selected item of the SelectionFormField. If the property value is -1, no item is selected and the currently selected item is deselected.

Syntax

<void> SelectionFormField.setSelectedIndex(<Boolean> index, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
index

The index of the selected item.

callback

Optional. Is called when the operation completed.

errorCallback

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

Examples

The following example demonstrates SelectionFormField.setSelectedIndex in a practical document-editing workflow. It sets the index of the selected item of the SelectionFormField. If the property value is -1, no item is selected and the currently selected item is deselected.

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

function configureSelectedIndex(selectionFormField) {
    selectionFormField.setSelectedIndex(
        true,
        function() {
            console.log("set selected index completed.");
        },
        onTxError
    );
}