addOptions() |
It is used to add options to the Select and List controls.
Syntax
Script |
oCollection = ControlID.addOptions(optionCollection, bTransaction, iInsertBeforeIndex, bAllowDuplicates) |
Return Value
Returns a collection of option objects that are added to the Select and List controls. The returned option contains the xml property, which contains their XML data node.
Values
optionCollection |
A collection of option objects. |
bTransaction |
Boolean which denotes whether the object has to be updated for transaction. The default value is true, which updates the data associated with the control. This also triggers the onchange event for enumerated Select and List controls. |
iInsertBeforeIndex |
Integer that denotes the index before adding the select or list options. |
bAllowDuplicates |
Boolean that denotes whether duplicate items can be allowed in the List control. The default value is true. If this property is set to false, then the optionCollection method contains uniquely added options. |
Remarks
The optionsCollection method contains option objects. The following table lists the properties of an option object.
value |
A string that is not available to the user. It is taken internally taken for transaction. |
description |
String that is available to the user. |
If the Select or List control exists in an XForm or in a grouping control in the XForm, use this method in the event handler which is executed when the Init Done event is fired.
If the Select or List control exists in a Table control, use this method in the event handler which is executed when the onBeforeBind event is fired. In this case, set the bAllowDuplicates parameter to False to avoid duplication of options.
Note:
The value that you add to the Select or List control is not selected, by default.
Example
This sample code demonstrates how the method can be used to add multiple options to a Select control, after the XForm is loaded.
// OnClick event of "addUsers" button. function addUsers_Click(eventObject) { // create the options to add. var optionCollection = new Array(); optionCollection[0] = {value:"100", description:"John"}; optionCollection[1] = {value:"200", description:"Nancy"}; optionCollection[2] = {value:"300", description:"Andrew"}; // add the options to the "employeeid" select control as the first option. // added options will participate in transaction employeeid.addOptions(optionCollection, true,0,false); }
The following code demonstrates how the method can be used to add multiple options to a Select control in a table, after the XForm is loaded.
// Adding an option to a select control in table. // OnClick event of "addUsers" button. function addUsers_Click(eventObject) { // create the options to add. var optionCollection = new Array(); optionCollection[0] = {value:"100", description:"John"}; optionCollection[1] = {value:"200", description:"Nancy"}; optionCollection[2] = {value:"300", description:"Andrew"}; // add the options to the "employeeid" field of the active row. employeeid[EmployeesTable.getIndex()].addOptions(optionCollection,true,0,false); }