Promotic
Login logon

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) - Cells have no borders.
1 - Cells have borders.
title[optional] (String) Window header, if the window with header is displayed (for target:_blank;)
multiselect[optional] (Long) Enables or disables multiple selection of options.
If the multiple selection is enabled, then a column with checkboxes will appear on the left side of the table. By checking the checkboxes on individual rows, we add options to the multiple selection, or by unchecking them, we remove them from the multiple selection.
If the table has a header, then a checkbox will appear in the left column of the header, which can be used to select or deselect all options at once.
If multiple selection is enabled, then ev.ReturnValue parameter contains an PmArray of identifiers for the individual selected options, and ev.ReturnIndex parameter contains an PmArray of indexes for the individual selected options in the original unsorted array.
0 (default) - Multiple selections are disabled.
1 - Multiple selections are enabled.
filterEnable[optional] (Long) Enables or disables filtering of table rows.
If filtering is enabled, then a "Filter" button appears in the upper-left corner of the window. Clicking it opens a window for entering the search text.
If the search text is not empty, then only those table rows in which the entered text was found will be displayed. The other table rows will be hidden. At the same time, the search text will be displayed to the right of the "Filter" button.
If the search text is empty, then all rows of the table will be displayed.
0 (default) - Filtering of table rows is disabled. The "Filter" button will not be displayed.
n - Filtering of table rows is enabled, if the number of table rows is higher than or equal to "n". Thus, e.g. the specified value 10 means that the "Filter" button will be displayed, if the table has at least 10 rows.
filterCol[optional] (Variant) Specifies the table columns in which the specified text will be searched when filtering rows.
all (default) - The entered text will be searched for in all columns of the table.
n - The entered text will be searched for only in the column with "n" index.
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 - Identifier (String) of the selected option, or an PmArray of identifiers for the individual selected options, if the multiple selections are enabled in the table.
ev.ReturnIndex - Index of the selected option in the original unsorted array, or an PmArray of indexes for the individual selected options, if the multiple selections are enabled in the table.
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.34 SCADA system documentation MICROSYS, spol. s r.o.

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