Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

Use the Table Genie

  • Last UpdatedJul 18, 2023
  • 3 minute read

There are two ways to populate data to the table:

  1. Set cell value directly to the table.

  2. Binding a Cicode function to return the value for the individual cells of the table.

Example 1

Set cell value directly to the table

In this case, the value is stored with the table. You will need to set a new value to the individual cell of the table if required.

The Cicode sample below will be used in the following example. Open the Cicode Editor and create a new cicode file, for example, _MyTable_Ex1.ci

//Callback function to respond to the initialization event of the table genie
INT FUNCTION MyTable_Init(STRING sTable)

// Add your columns

LibTable_AddColumn(sTable, "Column1", 150);

LibTable_AddColumn(sTable, "Column2", 100);


// Add data directly to the table

MyTable_AddRow(sTable, "Value for Cell(1,1)", "Value for Cell(1,2)");

MyTable_AddRow(sTable, "Value for Cell(2,1)", "Value for Cell(2,2)");

MyTable_AddRow(sTable, "Value for Cell(3,1)", "Value for Cell(3,2)");

RETURN TRUE;

END

//?Function to add a new row of data to the table

INT FUNCTION MyTable_AddRow(STRING sTable, STRING sCol1Value, STRING sCol2Value)

// Add data to the table, and the data is stored in the table

INT nRow = LibTable_SetCellValue(sTable, -1, 1, sCol1Value);

RETURN LibTable_SetCellValue(sTable, nRow, 2, sCol2Value);

END

  1. From the Graphics Builder create a new page (E.g. the Normal Tab Style Page)

  2. When created, from the Object toolbox select -> The Paste Genie icon.

  3. In the Paste Genie window select the lib_controls library

  4. Select the Table genie. The Table genie is pasted onto the graphics page.

  5. In the Table Genie property dialog, configure the fields according to the table below. Click OK to save your changes.

  6. Save the graphics page and compile and run the project.

    Parameter

    Description

    Table Name

    Table 1

    Width

    400 (all columns within the table are displayed. If left at 100 some columns may not be displayed)

    Number of rows

    10

    Header Height

    18

    Row Height

    15

    Header Padding

    5

    Row Padding

    4

    Column Padding

    5

    Horizontal Scrollbar

    Vertical Scrollbar

    Initialize

    MyTable_Init("#Name")

    At runtime the table will look like the following:

    Example 2

    Binding a Cicode function to return the value for the individual cells of the table

    This is similar to setting a formula in Excel. With binding, cell values are not stored in the table. The table will call the provided Cicode function when it needs data.

    The Cicode sample below will be used in the following example. Open the Cicode Editor and create a new cicode file, for example, _MyTable_Ex2.ci

    INT FUNCTION MyTable_InitDyn(STRING sTable)

    // Add your columns

    LibTable_AddColumn(sTable, "Column1", 150);

    LibTable_AddColumn(sTable, "Column2", 100);


    // Bind callback function for data display

    LibTable_SetDataTask(sTable, "Value", "MyTable_GetCellValue", "^"#Name^",#Row,#Col");


    // Set the number of rows for the table

    LibTable_SetPropertyInt(sTable, "RowCount", 9);


    RETURN TRUE;

    END

    //Function to return the value for a data cell

    STRING FUNCTION MyTable_GetCellValue(STRING sTable, INT nRow, INT nCol)

    IF (nRow > LibTable_GetPropertyInt(sTable, "RowCount")) THEN

    RETURN "";

    END

    RETURN "Dyn. value for Cell(" + nRow:# + "," + nCol:# + ")";

    END

    1. As in example 1, add a table library control to the graphics page.

    2. In the Table Genie property dialog, configure the fields according to the table below. Click OK to save the changes.

    3. Compile and then run the project.

      Parameter

      Description

      Table Name

      MyTable2

      Width

      400 (all columns within the table are displayed. If left at 100 some columns may not be displayed)

      Number of rows

      10

      Header Height

      18

      Row Height

      15

      Header Padding

      5

      Row Padding

      4

      Column Padding

      5

      Horizontal Scrollbar

      Vertical Scrollbar

      Initialize

      MyTable_InitDyn("#Name")

      At runtime the table will look like the following:

      See Also

      Use the Library Controls

      In This Topic
      TitleResults for “How to create a CRG?”Also Available in