Versions Compared

Key

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

The SimpleWidget and SimpleWidgets client-side classes provide the methods for widget structure and functionality customization:

  • Use the s_widget object of the SimpleWidget class to implement the required functionality. The object becomes available when a widget you create is initialized.

  • Use the s_widgets object of the SimpleWidgets class to implement the required functionality. The object is initialized when you add a widget to a form or a portal page.

  • To create your own widget methods, use the s_widget_custom.

    Info

    These methods can only be used on the client-side.

Notes_widget is an object of the

SimpleWidget

class that becomes available when a widget you create is initialized.


s_

widgets is an object of the SimpleWidgets class, initialized when you add a widget to a form or a portal page.

SimpleWidget

s_widget


Use the s_widget object to perform the current widget customization with the methods below.

Info

To manually invoke the method, pass the widget instance ID as the first parameter in the console. For example, to call the following method:

Code Block
languagejs
s_widget.getFieldValue(key); 

use the following approach:

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


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


Use this method to add a child template to the existing template by its ID with one of the following types: inner, before, after.

Parameters:

NameTypeMandatoryDefault value
idStringYN
templateStringYN
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.


N
typeStringN

inner 

Info

Available options: inner, before, after.


Return:

TypeDescription
VoidThis method does not return a value.

Example:

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


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

s_widget.getElements()


Use this method to return the widget structure elements collected in an array.

Return:

TypeDescription
Array of <elements>HTML elementsThis method returns an array of the The widget structure elements are collected in an array.

Example:

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

s_widget.getFieldValue(key)


Use this method to return the data value of the widget that is defined by the key option.

Parameter:

NameTypeMandatoryDefault value
keyStringYN

Return:

TypeDescription
AnyThe This method returns the value of the field that is defined by the key.

Example:

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

s_widget.getId()


Use this method to return a widget instance ID.

Return:

TypeDescription
StringThis method returns a widget instance ID.

Example:

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

s_widget.getOptionValue(key)


Use this method to return an option value that is defined by the key.

Parameter:

NameTypeMandatoryDefault value
keyStringYN

Return:

TypeDescription
AnyA This method returns a value of the widget option that is defined by the key.

Example:

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

s_widget.removeTemplate(id)


Use the method to remove all child nodes and content from the specified element. It does not remove the element itself or its attributes.

Parameter(s):

NameTypeMandatoryDefault value
idStringYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

Code Block
languagexml
themeEclipse
titleTemplate field
linenumberstrue
<div id="element1">
  Remove
</div>
<button buttonType="approve" event-click="window.s_widget_custom.remove();">
  Add
</button>


Code Block
languagecss
themeEclipse
titleCSS field
linenumberstrue
#element1 {
  background-color: yellow;
  height: 20px;
}


Code Block
languagejs
themeEclipse
titleClient 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)


Use this method to set a value for the key.

Info

If the value parameter is equal tonull, for example, s_widget.setFieldValue('subject', null), the defined field is cleared.

Parameters:

NameTypeMandatoryDefault value

key

StringYN
valueAnyYN

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()


Use this method to transfer the data to a server, where the widget server script runs. As a result, the widget data is updated.

Return:

TypeDescription
ObjectThis method returns a promise containing Promise object that contains a server response.

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)


Use this method to set a value using the key of the widget option.

Parameters:

NameTypeMandatoryDefault value
keyStringYN
valueAnyYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

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

s_widget.showData()


The Use the method displays to display the 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();

SimpleWidgets

s_widgets


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

s_widgets.getFieldValue(widgetInstanceID, key)


Use this method to return the data value of the widget for the key and widget instance ID.

Parameters:

NameTypeMandatoryDefault value
widgetInstanceIDStringYN
keyStringYN

Return:

TypeDescription
AnyReturns This methd returns the object value.

Example:

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

s_widgets.getForm()


Use this method to return a form object that is placed using the <Form> or <remform> tag.

Parameter:

NameTypeMandatoryDefault value
nameStringYN

Return:

TypeDescription
ObjectThis method returns a SimpleForm object.

Example:

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

s_widgets.getWidgets()


Use this method to return a list of all the IDs of the widgets instances located on the page.

Return:

TypeDescription
ArrayA This method returns a list of all the IDs of the widgets instances located on the page.

Example:

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

s_widgets.setFieldValue(widgetInstanceID, key, value)


Use this method to set a value for the key in the widget data, and the widget instance ID.

Parameters:

NameTypeMandatoryDefault value
widgetInstanceIDStringYN
keyStringYN
valueAnyYN

Return:

TypeDescription
VoidThis method does not return a value.

Example:

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


Table of Contents
maxLevel3
classfixedPosition