Note |
---|
s_widget это объект класса SimpleWidget, который инициализируетя внутри виджета при создании. s_widgets это объект класса SimpleWidgets, который инициализируется при добавлении виджета на форму или на страницу портала. |
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Для того чтобы вручную вызвать метод в консоли, передайте ID экземпляра виджета в первом параметре. Например, чтобы вызвать метод: 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Этот метод добавляет дочерний шаблон к существующему по его ID с одним из следующих типов: inner, before, after.
Параметры:
Название | Тип | Обязательный | Дефолтное значение |
---|
id | String | Д | Н |
template | String | Д | Н |
script | String | Н Note |
---|
Для настройки патаметра параметра type этот параметр является обязательным. Если параметр script не используется, используйте (''), как показано в примере ниже. |
| Н |
type | String (возможные варианты: inner, before, after) | Y | inner Tooltip |
---|
onlyIcon | true |
---|
appendIcon | info-filled |
---|
iconColor | blue |
---|
| Если не указано. |
|
Возврат:
Тип | Описание |
---|
Void | Данный метод не возвращает значение. |
Пример:
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'); |
Данный метод возвращает элемент виджета structure.
Возврат:
Тип | Описание |
---|
array<elements> | Элементы структуры виджета, собранные в массив. |
Пример:
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.Используйте этот метод для получения значения поля виджета, определенного опцией key.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|
key | String | Д | Н |
Возврат:
Тип | Описание |
---|
mixed | Значение поля определенное указанным ключом. |
Пример:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getFieldValue |
---|
linenumbers | true |
---|
|
s_widget.getFieldValue('element'); |
Данный метод возвращает объект формы, размещенный при помощи тэга <Form> или <remform>.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|
name | String | Д | Н |
Возврат:
Тип | Описание |
---|
Object | Метод возвращает объект SimpleForm. |
Пример:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getOptionValue |
---|
|
const builtInForm = s_widgets.getForm('custom');
await builtInForm.save(); |
Данный метод возвращает ID экземпляра виджета как значение строки.
Возврат:
Тип | Описание |
---|
String | Метод возвращает ID экземпляра виджета. |
Пример:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widget.getId |
---|
linenumbers | true |
---|
|
s_widget.getId(); |
Используйте данный метод для возврата опции виджета value, определенной опцией key.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|
key | String | Д | Н |
Возврат:
Тип | Описание |
---|
mixed | Значение опций виджета определено ключом. |
Пример:
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Используйте данный метод, чтобы удалить все дочерние узлы и содержимое указанных элементов. Сами элементы и аттрибуты при этом сохраняются.
Параметр:
Название | Тип | Обязательный | Дефолтное значение |
---|
id | String | Д | Н |
Возврат:
Тип | Описание |
---|
Void | Данный метод не возвращает значение. |
Пример:
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Используйте этот метод, чтобы задать значение (value) при помощи ключа (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Н |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Void | This method does not return a valueДанный метод не возвращает значение. |
ExampleПример:
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. |
Данный метод предназначен для переноса данных виджета на серверный скрипт и обновления данных виджета после ответа сервера.
Возврат:
Тип | Описание |
---|
Object | Метод возвращает промис, содержащий определенные данные. |
Пример
Example:
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.
Используйте этот метод, чтобы настроить значение(value) опции виджета при помощи ключа (key).
Параметры:
Название | Тип | Обязательный | Дефолтное значение | Name | Type | Mandatory | Default Value |
---|
key | String | YД | NН |
value | mixed | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Void | This method does not return a valueДанный метод не возвращает значение. |
ExampleПример:
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. |
Используйте этот метод для отображения данных поля виджета в консоли.
Возврат:
Тип | Описание |
---|
Void | Данный метод не возвращает значение. |
Пример
Example:
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Вызывайте метод s_widgets в своих скриптах при добавлении виджета на форму или страницу для взаимодействия с виджетом.
This method returns the objectvalue using the key and Данный метод возвращает значение объекта при помощи ключа (key) и ID экземпляра виджета (widget instance ID).
Parameter(s)Параметры:
NameНазвание | TypeТип | MandatoryОбязательный | Default ValueДефолтное значение |
---|
widgetInstanceID | String (the значение sys_id value) | YД | NН |
key | Integer | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
mixed | Returns the object valueВозвращает значение объекта. |
ExampleПример:
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. |
Этот метод возвращает список ID всех экземпляров виджетов на странице.
Возврат:
Тип | Описание |
---|
List<String> | Список ID объектов типа строка |
Пример
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | s_widgets.getWidgets |
---|
|
s_widgets.getWidgets(); |
This method sets the value using the key and the Используйте данный метод для настройки значения (value) поля при помощи ключа(key)и ID экземпляра виджета (widget instance ID).
Parameter(s)Параметры:
NameНазвание | TypeТип | MandatoryОбязательный | Default ValueДефолтное значение |
---|
widgetInstanceID | String (the значение sys_id value) | YД | NН |
key | Integer | YД | NН |
value | mixed | YД | NН |
ReturnВозврат:
TypeТип | DescriptionОписание |
---|
Void | This method does not return a valueМетод не возвращает значение. |
ExampleПример:
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() {
//
} |