User Interface
With this namespace, you can quickly provide methods to show UI.
The namespace User Interface provides to developers, methods to easily show or validate data.
//accessing to ui methods
SW.UI.{methodName}
editComponentsOptionInBulk
Description
This method can be used to edit an option in various components.
Method(s)
1 function editComponentsOptionInBulk(components: any[], option: string, value: any): void
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
components | any[] | true | Components array to edit option | |
option | string | true | Option to edit | |
value | any | true | New option value |
Basic Usage
SW.UI.editComponentsOptionInBulk([dataGrid, chart], "dataSource", data);
Response
It will set dataGrid and chart dataSources with the variable data passed.
getEntityImage
Description
This method can be used to get entities image.
Method(s)
1 function getEntityImage(element: HTMLElement, documentName: string,
2 params?: {
3 size?: Size;
hideName?: boolean;
title?: string;
4 } = {
5 size: Size.SMALL,
hideName: false,
title: null
6 }
7 ): string;
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
element | HTMLElement | true | HTML element | |
documentName | string | true | Type of document | |
size | Size | false | "small" | Image's size to be displayed(small, medium, large) |
hideName | boolean | false | false | Show or hide the name of the field |
Title | string | false | false | The name displayed in the UI |
Basic Usage
SW.UI.getEntityImage(element, "job", { size: "large" });
Response
Returns the passed HTML element with the entity job image.
setAttribute
Description
This method can be used to set element's attributes.
Method(s)
1 function setAttribute(element: HTMLElement, attribute: string, attributeValue: string,
2 params: {
3 text?: string;
4 createContainer?: boolean
5 } = {
6 createContainer: true
7 }
8 ): HTMLElement
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
element | HTMLElement | true | HTML element | |
attribute | string | true | Attribute to update | |
attributeValue | string | true | Value to update attribute | |
text | string | false | Inner HTML | |
createContainer | boolean | false | Create a new div container |
Basic Usage
SW.UI.setAttribute(element, "style", "display: contents");
Response
It will add the attribute value to the given attribute.
setConditionalColor
Description
This method can be used to set element's attributes.
Method(s)
1 function setConditionalColor(element: HTMLElement, value: string, conditions: boolean[], colors: string[],
2 params: {
3 createContainer?: boolean;
4 bold?: boolean;
5 italic?: boolean
6 } = {
7 createContainer: true
8 }
9 ): void
| Parameter | Type | Required | Defaults | Description |
|---|---|---|---|---|
element | HTMLElement | true | HTML element | |
value | string | true | Value to show | |
conditions | boolean[] | true | Conditions to check | |
colors | string[] | true | Colors for conditions | |
createContainer | boolean | false | true | Create a new div container |
bold | boolean | false | Bold font | |
italic | boolean | false | Italic font |
Basic Usage
SW.UI.setConditionalColor(element, 'Value', [1>0, 1=0, 1<0], ['Red', 'Green', 'Blue']);
Response
It will add the value text to the element with the background color corresponding to the condition that is true.