create

[ Function ] [ Deprecated ]

public static create(
    element: string,
    unused?: null,
    parent?: TcHmi.Controls.System.baseTcHmiControl | null
): TcHmi.Controls.System.baseTcHmiControl | undefined;

Function for programmatically creating control instances based on an HTML string.

create 1:

From version 1.10 this function is considered obsolete. Instead, the function createEx should be used.

create 2:

From version 1.8, the type was a short version of the name with prefix 'tchmi-', e.g. 'tchmi-button'. Since version 1.12 the namespace is part of the type. So, for example, the new name is 'TcHmi.Controls.Beckhoff.TcHmiButton'. The system also recognizes the old names and automatically converts them accordingly.

Parameter

Name

Type

Description

element

string

New control as HTML source code

unused [ optional ]

null

Must be set if parent is to be used.

parent [ optional ]

TcHmi.Controls.System.baseTcHmiControl

Parent control of the new control. This is used to check access rights if they depend on the parental control, for example.

 

This parameter should not be set if a control is created dynamically at application level ( CodeBehind ) and then passed to a ContainerControl (View, Content, Container etc.). The parent/child relationship is created dynamically when the control is added to the corresponding ContainerControl using the addChild function.

 

If a control is created dynamically within another control, this other control is the logical parent control and must be passed when the new control is created, so that properties such as access rights can be applied to the child control, and the system has the option to destroy the child control if the parent control is destroyed.

Return value

Type

Description

TcHmi.Controls.System.baseTcHmiControl, undefined

The control object or undefined in the event of an error.

create 3:

Available from 1.8

Sample - JavaScript

// Create control within another control
var childControl = TcHmi.ControlFactory.create(
    '<div id="newbutton" data-tchmi-type="tchmi-button"></div>',
    null,
    myControl
);
if(childControl!== undefined) {
    // append control to ourself
    myControl.getElement().append(childControl.getElement());
}