Promotic
Login logon

CreateItem - method of the PmForm object

Description:
Creates a single form item.
Syntax:
Object CreateItem(String sType, [String sId], [String sTitle], [String sProps], [String sPars])
Parameters:
sType(String) Pmf object type. Based on this type the corresponding object is created.
This value can later be detected by means of the PmfObject.Type property.
"string" - Creates object PmfString = Text input
"number" - Creates object PmfNumber = Integer or real number input
"bool" - Creates object PmfBool = Boolean value input item (Checkbox)
"enum" - Creates object PmfEnum = Selection of one of multiple items (Combobox)
"button" - Creates object PmfButton = Button
"layout" - Creates object PmfLayout = Area for other Pmf objects
"separ" - Creates object PmfSepar = Separator between configurators
"table" - Creates object PmfTable = Table
"tree" - Creates object PmfTree = Tree
"auto" - The object type is determined automatically according to the information specified in the sProps parameter.
The KeyVal string first looks for a Type key whose values are the same as of the sType parameter and directly determine the type of the object.
If the Type key is not found, then the Format key is searched and the object type and subtype are determined by the format type.
If the format is of the Enum type and format string contains a table of Rows:{keyval}, then the PmfEnum object is created. and at the same time it is filled with all rows listed in the table.
sId[optional] (String) Pmf object identifier.
Identifier can be used for example for obtaining the Pmf object by the GetItem method or for testing in the oExtra.onChange event.
If the identifier is not defined or has the value null then it is not possible to refer to this object.
This value can later be detected by means of the PmfObject.Id property.
sTitle[optional] (String) Displayed name of the Pmf object.
The name is by default displayed to the left of the configurator.
If needed, then the system adds "colon" character to the name.
If the name is an empty string then it is not displayed, but its area is allocated (the TitlePos property is unchanged).
If name is not set or has the value null then it is not displayed and its area is not allocated (simultaneously the the TitlePos property is set to "no").
This value can later be detected or modified by means of the PmfObject.Title property.
sProps[optional] (String) Initial values of properties of the created object. The syntax of this parameter is "PropertyName:Value;...". Entries are in the KeyVal format.
For example when creating the PmfNumber object can be entered: "Min:0;Max:100;"
sPars[optional] (String) Parameters of created Pmf object. Define where the object will be created. "parent:$sys;pos:after=xy". Entries are in the KeyVal format.
parent:id - Specifies in which PmfLayout object the object will be created.
The default value is $main.
pos:before=id - Create the object in front of the object created previously with id identifier.
pos:after=id - Create the object behind the object created previously with id identifier.
pos:first - Inserts the object as first.
pos:last (default) - Inserts the object as last.
Note:
This method is also functional in Web panels.
See also:
- PmForm.GetItem (method)
Example1:
JavaScriptSelect and copy to clipboard

var oString = oForm.CreateItem("string", "IdStr", "String", "Value:text;");
var oInt = oForm.CreateItem("auto", "IdInt", "Integer", "Type:number;Value:24;");
var oFloat = oForm.CreateItem("auto", "IdFloat", "Real number", "Format:{Type:Float;DLen:3;};Value:14.85642;");
var oEnum = oForm.CreateItem("auto", "IdEnum", "Color", "Format:{Type:Enum;Rows:{0:{v:1;n:red};1:{v:2;n:green};2:{v:3;n:blue};};};");

History:
Pm9.00.32: New value of the sType parameter: auto.
Pm8.03.08: Created
PROMOTIC 9.0.32 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.Update cookies preferences