Promotic

Příklad: Vytvoří PmForm okno s tabulkou

Příklad na vytvoření tabulky ve skriptu např. po stisknutí tlačítka v události onButtonUp.
JavaScriptVyber a zkopíruj do schránky

// Initialize Table - count rows, cols
var nBodyRow = 15;
var nBodyCol = 8;
var nHeadRow = 1;
var nLeftCol = 1;
var nFootRow = 1;
var oTable, oRow, iRow, iCol, oArea11, oArea21, oArea12, oArea22, oArea13, oArea23;


function onViewLoad(ev)
{
// Vytvoří objekt formuláře
var oForm = ev.Form;
oForm.Title = "Table Promotic";

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:
oArea11 = oTable.GetArea(11);

oArea11.BgColor = "#ffffff";
for (iRow = 0; iRow < nBodyRow; iRow += 1)
{
oRow = oArea11.GetRow(iRow);
for (iCol = 0; iCol < nBodyCol; iCol += 1)
{
oRow.GetCell(iCol).Value = "r" + iRow + "c" + iCol;
}
}

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

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

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

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

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


function onViewClose(ev)
{
if (ev.CloseReason == "ok")
{
var nRow = oTable.GetSel(0).Row;
Pm.Debug("Row(" + nRow + ").GetSel(0).Value=" + oArea11.GetRow(nRow).GetCell(0).Value);
}
}

// Vytvoří PmViewCreator - Objekt umožňuje otevřít různé typy prohlížečů
var oCreator = Pm.CreateView(null, "/#glob/form", "", "target:_blank;modal:1;pos:view," + pMe.ViewX + "," + pMe.ViewY + ";size:800,400;");
oCreator.View.onLoad = onViewLoad;
oCreator.View.onClose = onViewClose;

// Otevře formulář v modálním okně:
oCreator.Open();
© MICROSYS, spol. s r.o.