Note |
---|
s_widget is an object of the SimpleWidget class initialized within a widget you create. s_widgets is an object of the SimpleWidgets class initialized when you add a widget to a form or a portal page. |
The widget API describes methods and custom method declarations for widget structure and functionality customization:
- Use s_widget and s_widgets methods in client-side scripts to implement the widget functionality you need.
- If you need to create your own widget methods, use the custom method functionality.
Info |
---|
These methods can be used on the client-side only. |
To perform the current widget customization you created, use the methods below.
Info |
---|
title | Manual console invoke |
---|
|
In the console, to manually invoke the method, pass the widget instance ID as the first parameter. Ex.For example, to call the following method: Code Block |
---|
| s_widget.getFieldValue(key); |
use the method instead: Code Block |
---|
| s_widget.getFieldValue(widgetId, key); |
|
This method adds a child template to the existing template by its ID with one of the following types: inner, before, after.
Name | Type | Mandatory | Default Value |
---|
id | String | Y | N |
template | String | Y | N |
script | String | N Note |
---|
This parameter is mandatory if you need to define the type parameter. If no script is needed, then use an empty string ('') as in the example below. |
| N |
type | String (possible options: inner, before, after) | Y | inner Tooltip |
---|
onlyIcon | true |
---|
appendIcon | info-filled |
---|
iconColor | blue |
---|
| If not specified. |
|
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | xml |
---|
title | Add to a template field: |
---|
|
<div id="steps"></div> |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Add to a client script |
---|
|
s_widget.addTemplate('steps', '<div class="main">', '', 'inner'); |
This method returns the structure element structure of a widget.
Type | Description |
---|
array<elements> | The widget structure elements are collected in an array. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getElements() |
---|
linenumbers | true |
---|
|
window.s_widget.getElements(); |
Use this method to return the widget field value defined by the key option.
Name | Type | Mandatory | Default Value |
---|
key | String | Y | N |
Type | Description |
---|
mixed | The value of the field is defined by the key defined. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getFieldValue |
---|
linenumbers | true |
---|
|
s_widget.getFieldValue('element'); |
This method returns a form object that is placed using the <Form> or <remform> tags.
Name | Type | Mandatory | Default Value |
---|
name | String | Y | N |
Type | Description |
---|
Object | This method returns a SimpleForm object. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getOptionValue |
---|
|
const builtInForm = s_widgets.getForm('custom');
await builtInForm.save(); |
This method returns a widget instance ID as a string value.
Type | Description |
---|
String | This method returns a widget instance ID. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getId |
---|
linenumbers | true |
---|
|
s_widget.getId(); |
Use this method to return the a widget option option value defined by the key option.
Name | Type | Mandatory | Default Value |
---|
key | String | Y | N |
Type | Description |
---|
mixed | The value of the widget options is defined by the key. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getOptionValue |
---|
|
s_widget.getOptionValue('label'); |
The method removes all child nodes and content from the specified elements. It does not remove the element itself or its attributes.
Name | Type | Mandatory | Default Value |
---|
id | String | Y | N |
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
title | Add this to the Template field |
---|
linenumbers | true |
---|
|
<div id="element1">
Remove me
</div>
<button buttonType="approve" event-click="window.s_widget_custom.remove();">
Click me
</button> |
Code Block |
---|
language | css |
---|
theme | Eclipse |
---|
title | Add this to the CSS field |
---|
linenumbers | true |
---|
|
#element1 {
background-color: yellow;
height: 20px;
} |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Add this to the Client Script field |
---|
linenumbers | true |
---|
|
;
(() => {
window.s_widget_custom = window.s_widget_custom || {};
window.s_widget_custom.remove = function () {
s_widget.removeTemplate('element1');
}
})(); |
This method sets the a value using the key.
Info |
---|
If the value parameter is equal to 'null', for example, s_widget.setFieldValue ('subject', null) , the defined field will be is cleared. |
Name | Type | Mandatory | Default Value |
---|
key | String | Y | N |
value | mixed | Y | N |
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.setFieldValue |
---|
linenumbers | true |
---|
|
;
(async () => {
const tableName = s_form.getTableName();
const recordId = s_form.getUniqueValue();
const serviceId = s_form.getValue('service');
const serviceDisplayValue = s_form.getDisplayValue('service');
s_widget.setFieldValue('table_name', tableName);
s_widget.setFieldValue('record_id', recordId);
s_widget.setFieldValue('service', { database_value: serviceId, display_value: serviceDisplayValue });
await s_widget.serverUpdate();
})(); |
This method transfers widget data to a server script and updates widget data according to the server reply.
Type | Description |
---|
Object | This method returns a promise containing specific data. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.serverUpdate |
---|
linenumbers | true |
---|
|
;
(async () => {
const tableName = s_form.getTableName();
const recordId = s_form.getUniqueValue();
s_widget.setFieldValue('table_name', tableName);
s_widget.setFieldValue('record_id', recordId);
const response = await s_widget.serverUpdate();
console.log(response.getData().data);
})(); |
This method sets the a widget option option value using the key option.
Name | Type | Mandatory | Default Value |
---|
key | String | Y | N |
value | mixed | Y | N |
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.setOptionValue |
---|
|
s_widget.setOptionValue('label', 'name'); |
The method displays the field data of a widget in the console.
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.showData |
---|
|
s_widget.showData(); |
Invoke the s_widgets methods within your scripts, when adding a widget to a form, a page or for widgets interaction.
This method returns the objectvalue using the key and widget instance ID.
Name | Type | Mandatory | Default Value |
---|
widgetInstanceID | String (the sys_id value) | Y | N |
key | Integer | Y | N |
Type | Description |
---|
mixed | Returns the object value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widgets.getFieldValue |
---|
|
s_widgets.getFieldValue('157555401214600424', 'name'); |
This method returns all the widget instance IDs of the page.
Type | Description |
---|
List<String> | List A list of ID objects of the String type. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widgets.getWidgets |
---|
|
s_widgets.getWidgets(); |
This method sets the value using the key and the widget instance ID.
Name | Type | Mandatory | Default Value |
---|
widgetInstanceID | String (the sys_id value) | Y | N |
key | Integer | Y | N |
value | mixed | Y | N |
Type | Description |
---|
Void | This method does not return a value. |
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widgets.setFieldValue |
---|
|
s_widgets.getFieldValue('157555401214600424', 'name', 'Alex'); |
Within the client-side scripts, you can configure your own widget methods by using the window.s_widget_custom variable:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | Ex. |
---|
linenumbers | true |
---|
|
window.s_widget_custom.updateFullname = function() {
//
} |