selectedObjects

Specifies the selected values (not the labels) of the component as an array. Applies to multi-value input elements (Check Boxes) and selection elements (Selection Lists, Selection Trees, Range Slider, Calendars).

For a Calendar, selectedObjects specifies the selected range on the Calendar as an array of Dates, [selected_min,selected_max]. If the selected range falls outside the range of the Calendar’s data (specified by min and max), the selected dates are forced into the available range.

This property is readable and writable for Selection Lists, Selection Trees, and Calendars, and is read-only for other components. Script that reads the value of the selectedObjects property can be placed either on the component or in the onInit Handler or onRefresh Handler, while script that writes the selectedObjects property must be placed in the onInit Handler or onRefresh Handler. (See Add Dashboard Script for more information about these handlers.)

To avoid overwriting an existing setting (saved by the designer, or saved by the user in a bookmark), test to see if the component value has already been set before using selectedObjects. See the third example below.

Type

Array

array of selected option values

Examples

Example 1: Read a Selection List
var num = SelectionList1.selectedObjects.length;
var msg = 'You selected ' + num + ' objects: ';
msg += SelectionList1.selectedObjects.join(', '); (1)
alert(msg) (2)
1 Append the comma-separated list of selected items to the msg string.
2 Display the msg string.
Example 2: Set a Selection List
SelectionList1.selectedObjects=['CA','MA','TX'];
Example 3: Set two Calendars
Calendar1.selectedObjects = [Calendar1.min, dateAdd('m',3,Calendar1.min)]; (1)

if(Calendar2.selectedObjects[1] == null){
  Calendar2.selectedObjects = [CALC.today()]; (2)
}
1 Select a three-month range starting from the earliest date on the Calendar.
2 For a Calendar in day-selection mode, select today’s date ONLY IF not already set

Either syntax below can be used in component script:

selectedObjects               // unqualified
Component1.selectedObjects    // qualified

For onInit/onRefresh scripts, and for component and property scripts on other components, the second (qualified) form is required.