The view object (this)

The view object represents a view and is a self-contained runtime JavaScript object that can render itself in a browser.
When you are editing JavaScript in the view editor, the this keyword refers to the view.

Functions in the view object

You can access the following functions through the view object:

Table 1. Functions in the view object
Function Parameters Description
getData   Retrieves bound data that is associated with this view. The function works only for views with bound data.
Returned value
The getData function returns the value of the bound data as a JavaScript object. If there is no binding for the view, the returned value is undefined.
Example
var dec1 = <viewRef>.getData();
getOption
optionName (String)
The name of the option
Retrieves the option that is associated with this view.
Returned value
The getOption function returns the value of an option as a JavaScript object. If no such option exists or the option is not set for the view, the returned value is undefined.
Example
var dec1 = <viewRef>.getOption('option1');
setViewData
data (Object)
The value of the bound data. This parameter type must match the type of the bound data.
createPseudoBinding (Boolean)
If set to true, it creates a pseudo binding if there is no current binding.
Sets or updates the binding that is associated with this view.
  • Use it only with simple type bindings, or complex type bindings with simple type properties.
  • Do not use it with bindings that have properties that are lists or complex types. For complex types, set the bindings using the binding.set pattern, as described in Binding data and configuration options.
Example
MyView.setViewData("TEST"); //Updates bound data to the string 'TEST'
setOption
optionName (String)
The name of the option
optionValue (Object)
The value of the option. The type of this parameter must match the option type. No type checking is performed. Also, the option must be bound to a variable, and the binding cannot be static.
Updates the option data that is associated with the view. The setOption function works only for views with the specified option. If the view has no such option, a warning is logged in the browser console and the exception is re-thrown to the caller.
Example
<viewRef>.setOption("option1", "TestValue1");
getLabel   Retrieves the label value of the view.
Returned value
The getLabel function returns the label value of the view as a JavaScript string, htmlEscaped. If the view has no label, the returned value is undefined.
Example
var dec1 = <viewRef>.getLabel();
isLabelVisible   Returns a Boolean value to indicate whether the label is visible.
Returned value
The isLabelVisible function returns the label visibility status as a Boolean value. The returned value is false if labelVisibility is 'HIDDEN', or undefined. Otherwise, the returned value is true.
Example
var labelVisible = <viewRef>.isLabelVisible();
getLabelVisibility   Retrieves the label visibility setting of the view.
Returned value
The getLabelVisibility function returns the label visibility as a list of possible JavaScript string values, such as 'SHOW' and 'HIDE'. If no label visibility setting exists, the returned value is undefined.
Example
var labelVisible = <viewRef>.getLabelVisibility();
isVisible   Checks whether the view is visible.
Returned value
The isVisible function returns the visibility status adjusted based on the visibility of the parent view (Boolean). The returned value is false if visibility is set to 'NONE' or 'HIDDEN'. Otherwise, the returned value is true.
Example
var visible = <viewRef>.isVisible();
getVisibility   Returns the actual visibility of a view. It adjusts its value based on the visibility of the parent view.
Returned value
The getVisibility function returns the visibility of the view as a list of possible JavaScript string values, such as 'REQUIRED', 'EDITABLE', 'READONLY', 'NONE', and 'HIDDEN'. It adjusts its value based on the visibility of the parent view.
Example
var visible = <viewRef>.getVisibility();
getBaseTextDirection   Retrieves the baseTextDirection setting of the view.
Returned value
It returns the baseTextDirection setting of the view as a list of possible JavaScript string values, such as 'DEFAULT', 'CONTEXTUAL', 'LTR', and 'RTL'. If no such setting is set for the view, a 'DEFAULT' string is returned.
Example
var dec1 = <viewRef>.getBaseTextDirection();
getHelpText   Retrieves the help text of the view.
Returned value
The getHelpText function returns the helpText value of the view as a JavaScript string, htmlEscaped. If the view has no help text, it returns a null value.
Example
var dec1 = <viewRef>.getHelpText();