Component properties
There are several properties of the Component class that may contain objects of specific classes. Each of these classes are described in the sub-sections of this section.
On this page some functionality that is shared between these classes is described.
Custom JavaScript
For more complex applications it is possible to add custom JavaScript code that is executed in the front-end. This can reduce the need for communicating with the back-end. Custom JavaScript code can be used in the following places:
-
Component properties:
-
calculateValue
The JavaScript code must assign a value to variable
value
. -
customConditional
The JavaScript code must assign a boolean to variable
show
. Example
component_object.calculateValue = "value = data.other_component + 1;" component_object.customConditional = "show = data.other_component > 0;"
-
-
When the
type
field of the action dict/struct is set to 'value' or 'customAction', the JavaScript code in the action's 'value' or 'customAction' field must assign a value to variablevalue
. Example -
When the
type
field of the trigger dict/struct is set to 'javascript', the JavaScript code in the trigger's 'javascript' field must assign a boolean to variableresult
. Example -
Validate
custom
propertyThe JavaScript code must assign a boolean to variable
valid
. -
JavaScript code used in string template evaluation blocks.
In the JavaScript code the variables listed in the table below are available for use.
The usage numbers denote which variables are available for the places specified in the above list.
current component
refers to the component to which the custom JavaScript applies.
Variable | Usage | Description |
---|---|---|
input | 2, 4 | The new value that was put into the current component. |
form | 1, 2, 4, 5 | The complete form JSON object. |
submission | 1, 2, 4, 5 | The complete submission object. |
data | 1, 2, 3, 4, 5 | The complete submission data object. |
row | 1, 2, 3, 4, 5 | Contextual "row" data, used within DataGrid, EditGrid, and Container components. |
rowIndex | 1, 2, 3, 4, 5 | Contextual "row" number (zero-based). Can be used with row . |
component | 1, 2, 3, 4, 5 | The current component JSON object. |
instance | 1, 2, 4, 5 | The current component instance. |
value | 1, 2, 4, 5 | The current value of the component in the submission data. |
item | - | The Select component values. |
Execution of custom JavaScript depends on the JavaScript support provided by the browser the application is opened in. When the browser does not support JavaScript features that are used, errors and warnings may be printed in the browser's console. The application should continue to function, but functionality may differ from the expected functionality.
Note: For more complex JavaScript, it may be convenient to provide some JavaScript functions for use in any of the above. This can be achieved by providing a Custom JavaScript file.