The control ID is the unique ID of the view within the parent view. You can use the
control ID to access a subview instance at run time.
About this task
At design time, each view in a page is given a default control ID, which you can change.
This control ID is unique within the parent view. At run time, the parent view is rendered as a
<div></div> tag, which contains a nested <div></div>
tag for each child view. You can use the control ID to access an instance of the child view at run
time by identifying the <div></div> that contains the instance. Important: In view-based pages, views are reusable and you can have multiple views in a page.
The control ID is the value for the data-viewid attribute of a
<div></<div> tag. By using the data-viewid attribute,
view developers can locate the nested view because data-viewid is unique within
its parent or enclosing view.
Procedure
To use a control ID in your code:
- Go to the layout of your view and select the view that you want
to access at run time and display its properties.
Under General, the Control
ID field displays the view's unique ID.
-
In the Behavior properties, add JavaScript
code:
-
Get the control ID by using the this.context.getSubview(subViewId,
requiredOrder) method. The method returns an array of nested view instance objects. If
the result does not contain a set of repeatable objects, specify the first index of the returned
array list, for example this.context.getSubview("myCheckbox")[0]. If you need
the array in the same order as your document order, set the second optional parameter to true. By
default, it is set to false.
- subViewID
- The id parameter of the
<div></div> tag of the
nested view instance object
- requiredOrder
- A Boolean value. If set to true, the method returns the array of view
instance objects in the same order as the document tree. The default is false.
-
Enter your code to interact with the nested view instance as appropriate.
- Click Save or Finish editing.