Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example: Creates a PmForm window with table

Example of table creation in the script e.g. after pressing the button in the onButtonUp event.
JavaScriptSelect and copy to clipboard

//Initialize Table - count rows, cols
var nBodyRow = 15;
var nBodyCol = 8;
var nHeadRow = 1;
var nLeftCol = 1;
var nFootRow = 1;

var oRow, i, j;
var oForm = Pm.CreatePmForm();
oForm.Title = "Table Promotic";

var oTable = oForm.CreateItem("table", "id_table");
oTable.InitRows(nBodyRow, nHeadRow, nFootRow);
oTable.InitCols(nBodyCol, nLeftCol);
oTable.SetColWidth(6, 1, 0, -1);  //Table Column width
oTable.SetSel(0, 0);  //Table Set active row

//********** Body *********
//TableArea 11=MainBody:
var oArea11 = oTable.GetArea(11);
oArea11.BgColor = "#ffffff";
for (i = 0; i < nBodyRow; i += 1)
{
oRow = oArea11.GetRow(i);
for (j = 0; j < nBodyCol; j += 1)
oRow.GetCell(j).Value = "r" + i + "c" + j;
}

//TableArea 21=LeftBody:
if (nLeftCol)
{
var oArea21 = oTable.GetArea(21);
oArea21.BgColor = "#d0d0f0";
for (i = 0; i < nBodyRow; i += 1)
oArea21.GetRow(i).GetCell(0).Value = "Row" + i;
}

//********** Head *********
//TableArea 12=MainHead:
if (nHeadRow)
{
var oArea12 = oTable.GetArea(12);
oArea12.BgColor = "#d0d0d0";
var oHeadRow = oArea12.GetRow(0);
for (i = 0; i < nBodyCol; i += 1)
oHeadRow.GetCell(i).Value = "Col" + i;
}

//TableArea 22=LeftHead:
if (nHeadRow && nLeftCol)
{
var oArea22 = oTable.GetArea(22);
oArea22.BgColor = "#ffffca";
oArea22.GetRow(0).GetCell(0).Value = "PmfTable";
}

//********** Foot *********
//TableArea 13=MainFoot:
if (nFootRow)
{
var oArea13 = oTable.GetArea(13);
var oFootRow = oArea13.GetRow(0);
for (i = 0; i < nBodyCol; i += 1)
oFootRow.GetCell(i).Value = "Total" + i;
}

//TableArea 23=LeftFoot:
if (nFootRow && nLeftCol)
{
var oArea23 = oTable.GetArea(23);
oArea23.BgColor = "#caffff";
oArea23.GetRow(0).GetCell(0).Value = "Result";
}

//Opens form in modal window:
var oExtra = Pm.CreatePmMap();
oExtra.ViewObject = oForm;
oExtra.onClose = function(ev) { Pm.Debug("Row(0).GetSel(0).Value = " + oArea11.GetRow(0).GetCell(0).Value); };
pMe.PmPanel.OpenView("/#glob/form", "target:_blank;modal:1;size:750,400;", "", oExtra);
PROMOTIC 9.0.8 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