Add

function Add(
  sText: string = null,
  sValue: string = sText,
  nIndex: number = this.GetElementsCount(),
): boolean

Description

Adds a new value to the combo box / dropdown list content control.

Parameters

sTextstringdefault: null

The display text for the list item.

sValuestringdefault: sText

The list item value.

nIndexnumberdefault: this.GetElementsCount()

A position where a new value will be added.

Returns

boolean

Try It

var oDocument = Api.GetDocument();
Api.pluginMethod_AddContentControlList(1, [{Display: "Item1_D", Value: "Item1_V"}, {Display: "Item2_D", Value: "Item2_V"}], {"Id": 100, "Tag": "CC_Tag", "Lock": 3});
var aContentControls = oDocument.GetAllContentControls();
var oContentControlList = aContentControls[0].GetDropdownList();
oContentControlList.Add("Item3_D", "Item3_V", 2);
oDocument.AddElement(0, oContentControlList);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).