Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Object PmfTable

Description:
This object represents one form item of the type: "Table".
Properties and methods of this object:
BgColor Setting/getting the background color of the table
DeleteCol Deleting one or multiple columns
DeleteRow Deleting one or multiple rows
GetArea Returns reference to a certain table area (to the PmfTableArea object)
GetAreaWidth Returns current area width based on defined arguments
GetColAttr Reading parameters set to the table columns by the SetColAttr method
GetColWidth Reading the table column width
GetSel Detects selected rows or cells
HorzAlign Horizontal table text alignment
InitCols Initialization of table column count
InitRows Initialization of row count of the table
InsertCol Inserting one or more new columns
InsertRow Inserting one or more new rows
SelType The type of row or cells selection
SetColAttr Sets column parameters of the table
SetColWidth Sets columns width of the table
SetSel The entered row (or cell) in the table is marked as selected
TextColor Setting/getting the font color of the table
VertAlign Vertical alignment of the table text
Related objects:
PmfTableArea(Table area) The object represents table area (data area, header, footer or the left portion)
PmfTableColumn(Column of the table area) The object represents the column in the selected table area
PmfTableRow(Table area row) The object represents a row in selected table area
PmfTableCell(Table area cell) The object represents a cell in selected table area
Properties and methods that are common to all objects of the PmfObject type:
AddEvent Registers a function into selected event
BodyHeightIni Initial body height
BodyHeightMode Changing body height
BodyWidthIni Initial body width
BodyWidthMode Changing body width
Enabled Enable/disable editing of values.
Id Pmf object identifier
PrivateData Reading or writing private value into the object
RemoveEvent Deregisters the function in the specified event
Title Displayed name of the Pmf object
TitlePos Position of displayed Pmf object name
Type Pmf object type
Visible Sets the visibility/invisibility of Pmf object.
Events:
onAction Is triggered when an important logical action happens over the object
onSelChange Is triggered when another row or cell is selected
Note:
- The object can be created by the method PmForm.CreateItem("table", ..).
- This object is functional also in Web panels.
 
Areas in the table:

The table consists of 6 areas:

11 = MainBody = Main data area: The area is always visible.
12 = MainHead = Main area header: The area is visible only if number of rows in this area is non-zero.
13 = MainFoot = Main area footer: The area is visible only if number of rows in this area is non-zero.
21 = LeftBody = Left data area: The area is visible only if number of columns in this are is non-zero.
22 = LeftHead = Left area header: The area is visible only if the LeftBody and MainHead areas are visible.
23 = LeftFoot = Left area footer: The area is visible only if the LeftBody and MainFoot areas are visible.
 
In table initialization phase, the number of columns and the number of rows is set by methods InitCols and InitRows.

The number of columns and number of rows can be then modified dynamicaly by methods InsertCol, DeleteCol, InsertRow, DeleteRow.

 

Access to corresponding area is available by method GetArea.

Set the value of the cell in corresponding area:

oPmfTable.GetArea(11).GetRow(1).GetCell(2).Value = 3.14
Example:
Example of table creation in a script of the onFormLoad event of the PmgForm object.
JavaScriptSelect and copy to clipboard

var oTable, oTabFHead, oTabArea, oTabHead, oHeadRow, oTabLeftBody, oTabFLeft, oTabFooter, oFootRow, nRows, nCols, oRow, i, j;
var oForm = pMe.Form;
oForm.Title = "Table Promotic";

oTable = oForm.CreateItem("table", "id_table");
oTable.InitRows(5, 2, 1);  //nBodyRow, [nHeadRow, nFootRow]
oTable.InitCols(6, 1);  //nBodyCol, [nLeftCol]

//Table LeftHead
oTabFHead = oTable.GetArea(22);
oTabFHead.GetRow(0).GetCell(0).Value = "PmfTable";
oTabFHead.BgColor = "#ffffca";

//TableArea MainBody (Rows, Cols, BgColor)
oTabArea = oTable.GetArea(11);
nRows = oTabArea.RowCount;
nCols = oTabArea.ColCount;
oTabArea.BgColor = "#ffffff";

//Table MainHead (BgColor, Column titles)
oTabHead = oTable.GetArea(12);
oTabHead.BgColor = "#d0d0d0";
oHeadRow = oTabHead.GetRow(0);
for (i = 0; i < nCols; i += 1)
oHeadRow.GetCell(i).Value = "Col" + i;

//TableArea - MainBody (Values), LeftBody (Color, Rows titles)
oTabLeftBody = oTable.GetArea(21);
oTabLeftBody.BgColor = "#d0d0f0";
for (i = 0; i < nRows; i += 1)
{
oTabLeftBody.GetRow(i).GetCell(0).Value = "Row" + i;
oRow = oTabArea.GetRow(i);
for (j = 0; j < nCols; j += 1)
oRow.GetCell(j).Value = "r" + i + "c" + j;
}

//Table LeftFoot (Value, BgColor)
oTabFLeft = oTable.GetArea(23);
oTabFLeft.GetRow(0).GetCell(0).Value = "Result";
oTabFLeft.BgColor = "#caffff";

//Table MainFoot Values
oTabFooter = oTable.GetArea(13);
oFootRow = oTabFooter.GetRow(0);
for (i = 0; i < nCols; i += 1)
oFootRow.GetCell(i).Value = "Total" + i;

//Table Column width
oTable.SetColWidth("50px", 1, 0, nCols);

//Table Set active row
oTable.SetSel(0, 2);

History:
Pm9.00.04: Created
PROMOTIC 9.0.7 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice