Update cookies preferences
Promotic

Opening the viewer for option selection (/#glob/list)

The window for option selection from a list is opened by the Pm.CreateView method. In the sViewPath parameter the global path "/#glob/list" is entered.
Syntax:
JavaScriptVBScriptSelect and copy to clipboard

var oCreator = Pm.CreateView(null, "/#glob/list", sViewPars, sFramePars);
oCreator.Open();
Parameters of the Pm.CreateView method:
oFrom(Object) The object, which will mediate the opening of the viewer.
The object specifies the origin of the path, the relative position of the window, the parent, etc.
- The null value means the usage of:
- the PmaPanel object if CreateView method is called in the script of the Pmg object.
- active PmaWorkspace, if CreateView method is called in the script of the Pma object.
- If the the PmgFrame object is entered here (in the script of the Pmg object), then the viewer opens in this frame.
- If the the PmaPanel object is entered here (in the script of the Pma object), then the viewer opens in this selected object.

See the PmViewCreator.From property.
sViewPars(String) Viewer parameters (they differ for various viewer types).
See the PmViewCreator.View property.
Entries are in the KeyVal format. For example "autoselect:0;grid:1;title:Selection;".

Properties and events in the PmViewCreator.View object:
initValue[optional] (String) Initial selection (Identifier).
list(Array) 2-dimensional array with options, where the rows represent each option and the columns the option items. See (Col,Row) - 2-dimensional array meaning an array of rows.
The first column (zero-based index) is not displayed by the menu (it is invisible) and contains the identifiers of each option. The next columns are displayed in the menu. The menu is diplayed in the table form, having one column less than the used 2-dimensional array.
The first row may (not necessarily) contain the header with column titles (localized user names) in the menu. If first row is to contain the header, then in the first column (invisible, reserved for identifiers) there must be a string with $title value.
autoselect[optional] (Long) (Long) It allows to use the mode which is not requesting user input unless necessary. The window is not displayed.
0 (default) - the window will always be displayed.
1 - The window will be displayed only if there are at least two possible options.
If only a single option is available, then it is selected automatically and the method returns the value of the String type (selected option identifier).
If there is no option available then the method returns: null for JavaScript or Empty for VBScript (it can be tested by the Pm.IsValid method).
grid[optional] (Long) Specifies whether the cells of displayed table will have borders.
0 (default) - have no borders.
1 - have borders.
title[optional] (String) Window header, if the window with header is displayed (for target:_blank;)
onChange[optional] (Function) The event function for managing the event of viewer modification.
For JavaScript the function is entered.
For VBScript the PmAction object is entered.
 
The function has a single parameter ev containing information regarding the corresponding event.
ev.Value - (String) Currently selected option (Identifier).
ev.Index - (Long) Index of the currently selected option in the original unsorted array.
onClose[optional] (Function) The event function for managing the event of viewer closing.
For JavaScript the function is entered.
For VBScript the PmAction object is entered.
 
The function has a single parameter ev containing information regarding the corresponding event.
ev.CloseReason - (String) Identifier of the window closing type.
The value "ok" means a valid selection.
The value "cancel" or "" represent cancelled selection.
ev.ReturnValue - (String) Final selected option (Identifier).
ev.ReturnIndex - (Long) Index of the selected option in the original unsorted array.
sFramePars(String) Parameters for the frame where the viewer will be displayed.
See the PmViewCreator.Frame property.
Entries are in the KeyVal format, for example "target:_blank;".
The viewer parameters are in the form of the PmMap object that is filled from value of the sViewPars parameter (of the KeyVal type) in the Pm.CreateView method.
By filling from the KeyVal value all the parameters are initially stored as string. The content of the PmMap object can be then modified as needed - items can be modified, added and deleted.
The PmMap object can also contain other embedded PmMap objects (Submap). The PmMap.mapSetSubmapAt method can be used in order to create a new PmMap or make one accessible.
Example1:
Selection from the array of values
JavaScriptSelect and copy to clipboard

var aList = Pm.CreatePmArray().Create(2,3);
aList.SetItem("id1", 0, 0);
aList.SetItem("Test 1", 1, 0);
aList.SetItem("id2", 0, 1);
aList.SetItem("Test 2", 1, 1);
aList.SetItem("id3", 0, 2);
aList.SetItem("Test 3", 1, 2);

function onViewClose(ev)
{
if (ev.CloseReason == "ok")
{
switch (ev.ReturnValue)
{
case "id1":
Pm.Debug("Run test 1");
break;
case "id2":
Pm.Debug("Run test 2");
break;
case "id3":
Pm.Debug("Run test 3");
break;
}
}
}

var oCreator = Pm.CreateView(null, "/#glob/list", "autoselect:0;grid:1;title:Selection;", "target:_blank;modal:1;pos:view," + pMe.ViewX + "," + pMe.ViewY + ";");
oCreator.View.list = aList;
oCreator.View.initValue = "id2";
oCreator.View.onClose = onViewClose;
oCreator.Open();
Example2:
Selection from the list of panels. The Pm.FindViewers method returns the selection array.
JavaScriptSelect and copy to clipboard

function onViewClose(ev)
{
if (ev.CloseReason == "ok")
{
var sViewer = ev.ReturnValue;
if (Pm.IsValid(sViewer))
{
Pm.CreateView(null, sViewer, "", "target:main;").Open();
}
}
}

var oCreator = Pm.CreateView(null, "/#glob/list", "autoselect:0;grid:1;title:Selection;", "target:_blank;modal:1;pos:view," + pMe.ViewX + "," + pMe.ViewY + ";");
oCreator.View.list = Pm.FindViewers("groups:menu;viewers:panel;\",\"\", \"headers:;columns:path,title;");
oCreator.View.onClose = onViewClose;
oCreator.Open();

History:
Pm9.00.10: New parameters ev.ReturnIndex and ev.Index.
Pm9.00.09: Created
PROMOTIC 9.0.31 SCADA system documentation MICROSYS, spol. s r.o.

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