Note |
---|
s_widget это объект класса SimpleWidget, который инициализируетя внутри виджета при создании. s_widgets это объект класса SimpleWidgets, который инициализируется при добавлении виджета на форму или на страницу портала. |
The widget API describes methods and API виджетов описывает методы и 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 |
---|
Эти методы могут спользованы только на стороне клинтаклиента. |
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. 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.
Parameter(s)Параметры:
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, use an empty string ('') as in the example below. | Для настройки патаметра type этот параметр является обязательным. Если параметр script не используется, используйте (''), как показано в примере ниже. |
| НN |
type | String (possible optionsвозможные варианты: inner, before, after) | Y | inner Tooltip |
---|
onlyIcon | true |
---|
appendIcon | info-filled |
---|
iconColor | blue |
---|
| If not specifiedЕсли не указано. |
|
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Void | This method does not return a valueДанный метод не возвращает значение. |
ExampleПример:
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 of a widget.
Type | Description |
---|
array<elements> | The widget structure elements are collected in an array. |
Данный метод возвращает элемент виджета structure.
Возврат:
Тип | Описание |
---|
array<elements> | Элементы структуры виджета, собранные в массив. |
Пример
Example:
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.
Parameter(s)Параметр:
NameНазвание | TypeТип | MandatoryОбязательный | Default ValueДефолтное значение |
---|
key | String | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
mixed | The value of the field is defined by the key defined. |
ExampleЗначение поля определенное указанным ключом. |
Пример:
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.
Данный метод возвращает объект формы, размещенный при помощи тэга <Form> или <remform>.
Параметр:
Название | Тип | Обязательный | Дефолтное значение | Name | Type | Mandatory | Default Value |
---|
name | String | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Object | This method returns a SimpleForm objectМетод возвращает объект SimpleForm. |
ExampleПример:
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. |
Данный метод возвращает ID экземпляра виджета как значение строки.
Возврат:
Тип | Описание |
---|
String | Метод возвращает ID экземпляра виджета. |
Пример
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getId |
---|
linenumbers | true |
---|
|
s_widget.getId(); |
Use this method to return a widget option value defined by the key option.
Используйте данный метод для возврата опции виджета value, определенной опцией key.
Параметр:
Название | Тип | Обязательный | Дефолтное значение | Name | Type | Mandatory | Default Value |
---|
key | String | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
mixed | The value of the widget options is defined by the key. |
ExampleЗначение опций виджета определено ключом. |
Пример:
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.
Parameter(s)Параметр:
NameНазвание | TypeТип | MandatoryОбязательный | Default ValueДефолтное значение |
---|
id | String | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Void | This method does not return a valueДанный метод не возвращает значение. |
ExampleПример:
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 a value using the key.
Info |
---|
If the value parameter is equal to 'null', for example, s_widget.setFieldValue ('subject', null) , the defined field 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 a widget 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 or a page for widget 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> | 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() {
//
} |