Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


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

Эти методы могут спользованы только на стороне клинтаклиента.

s_widget


To perform the current widget customization you created, use the methods below.

Info
titleManual 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
languagejs
s_widget.getFieldValue(key); 

use the method instead:

Code Block
languagejs
s_widget.getFieldValue(widgetId, key);



s_widget.addTemplate(id, template, script, type)


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Дефолтное значение
idStringYДNН
templateStringYДNН
scriptString

Н 

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
typeString (possible optionsвозможные варианты: inner, before, after)Y

inner 

Tooltip
onlyIcontrue
appendIconinfo-filled
iconColorblue

If not specifiedЕсли не указано.

Return


Возврат:

TypeТипDescriptionОписание
VoidThis method does not return a valueДанный метод не возвращает значение.
Example

Пример:

Code Block
languagexml
titleAdd to a template field:
<div id="steps"></div>


Code Block
languagejs
themeEclipse
titleAdd to a client script
s_widget.addTemplate('steps', '<div class="main">', '', 'inner');

s_widget.getElements()

This method returns the structure element of a widget.

Return:

TypeDescriptionarray<elements>The widget structure elements are collected in an array.

Данный метод возвращает элемент виджета structure.

Возврат:

ТипОписание
array<elements>Элементы структуры виджета, собранные в массив.

Пример

Example

:

Code Block
languagejs
themeEclipse
titles_widget.getElements()
linenumberstrue
window.s_widget.getElements();

s_widget.getFieldValue(key)


Use this method to return the widget field value defined by the key option.

Parameter(s)

Параметр:

NameНазваниеTypeТипMandatoryОбязательныйDefault ValueДефолтное значение
keyStringYДNН
Return

Возврат:

TypeТипDescriptionОписание
mixedThe value of the field is defined by the key defined.
Example
Значение поля определенное указанным ключом.

Пример:

Code Block
languagejs
themeEclipse
titles_widget.getFieldValue
linenumberstrue
s_widget.getFieldValue('element');

s_widget.getForm()

This method returns a form object that is placed using the <Form> or <remform> tags.

Parameter(s):


Данный метод возвращает объект формы, размещенный при помощи тэга <Form> или <remform>.

Параметр:

НазваниеТипОбязательныйДефолтное значениеNameTypeMandatoryDefault Value
nameStringYДNН
Return

Возврат:

TypeТипDescriptionОписание
ObjectThis method returns a SimpleForm objectМетод возвращает объект SimpleForm.
Example

Пример:

Code Block
languagejs
themeEclipse
titles_widget.getOptionValue
const builtInForm = s_widgets.getForm('custom');
await builtInForm.save();

s_widget.getId()

This method returns a widget instance ID as a string value.

Return:

TypeDescriptionStringThis method returns a widget instance ID.

Данный метод возвращает ID экземпляра виджета как значение строки.

Возврат:

ТипОписание
StringМетод возвращает ID экземпляра виджета.

Пример

Example

:

Code Block
languagejs
themeEclipse
titles_widget.getId
linenumberstrue
s_widget.getId();

s_widget.getOptionValue(key)

Use this method to return a widget option value defined by the key option.

Parameter(s):


Используйте данный метод для возврата опции виджета value, определенной опцией key.

Параметр:

НазваниеТипОбязательныйДефолтное значениеNameTypeMandatoryDefault Value
keyStringYДNН
Return

Возврат:

TypeТипDescriptionОписание
mixedThe value of the widget options is defined by the key.
Example
Значение опций виджета определено ключом.

Пример:

Code Block
languagejs
themeEclipse
titles_widget.getOptionValue
s_widget.getOptionValue('label');

s_widget.removeTemplate(id)


The method removes all child nodes and content from the specified elements. It does not remove the element itself or its attributes.

Parameter(s)

Параметр:

YN
NameНазваниеTypeТипMandatoryОбязательныйDefault ValueДефолтное значение
idStringДН
Return

Возврат:

TypeТипDescriptionОписание
VoidThis method does not return a valueДанный метод не возвращает значение.
Example

Пример:

Code Block
languagexml
themeEclipse
titleAdd this to the Template field
linenumberstrue
<div id="element1">
  Remove me
</div>
<button buttonType="approve" event-click="window.s_widget_custom.remove();">
  Click me
</button>


Code Block
languagecss
themeEclipse
titleAdd this to the CSS field
linenumberstrue
#element1 {
  background-color: yellow;
  height: 20px;
}


Code Block
languagejs
themeEclipse
titleAdd this to the Client Script field
linenumberstrue
;
(() => {
    window.s_widget_custom = window.s_widget_custom || {};
    window.s_widget_custom.remove = function () {
        s_widget.removeTemplate('element1');
    } 
})();

s_widget.setFieldValue(key, value)


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.

Parameter(s):

NameTypeMandatoryDefault Value
keyStringYN
valuemixedYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titles_widget.setFieldValue
linenumberstrue
;
(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();
})();


s_widget.serverUpdate()


This method transfers widget data to a server script and updates widget data according to the server reply.

Return:

TypeDescription
ObjectThis method returns a promise containing specific data.

Example:

Code Block
languagejs
themeEclipse
titles_widget.serverUpdate
linenumberstrue
;
(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);
})();

s_widget.setOptionValue(key, value)


This method sets a widget option value using the key option.

Parameter(s):

NameTypeMandatoryDefault Value
keyStringYN
valuemixedYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titles_widget.setOptionValue
s_widget.setOptionValue('label', 'name');

s_widget.showData()


The method displays the field data of a widget in the console. 

Return:

TypeDescription
Void

This method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titles_widget.showData
s_widget.showData();

s_widgets


Invoke the s_widgets methods within your scripts, when adding a widget to a form or a page for widget interaction.

s_widgets.getFieldValue(widgetInstanceID, key)


This method returns the objectvalue using the key and widget instance ID.

Parameter(s):

NameTypeMandatoryDefault Value
widgetInstanceIDString (the sys_id value)YN
keyIntegerYN

Return:

TypeDescription
mixedReturns the object value.

Example:

Code Block
languagejs
themeEclipse
titles_widgets.getFieldValue
s_widgets.getFieldValue('157555401214600424', 'name');

s_widgets.getWidgets()


This method returns all the widget instance IDs of the page.

Return:

TypeDescription
List<String>A list of ID objects of the String type. 

Example:

Code Block
languagejs
themeEclipse
titles_widgets.getWidgets
s_widgets.getWidgets();

s_widgets.setFieldValue(widgetInstanceID, key, value)


This method sets the value using the key and the widget instance ID.

Parameter(s):

NameTypeMandatoryDefault Value
widgetInstanceIDString (the sys_id value)YN
keyIntegerYN
valuemixedYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

Code Block
languagejs
themeEclipse
titles_widgets.setFieldValue
s_widgets.getFieldValue('157555401214600424', 'name', 'Alex');

Anchor
Custom method
Custom method
s_widget_custom


Within the client-side scripts, you can configure your own widget methods by using the window.s_widget_custom variable:

Code Block
languagejs
themeEclipse
titleEx.
linenumberstrue
window.s_widget_custom.updateFullname = function() {
  //
}


Table of Contents
maxLevel3
classfixedPosition