Language Reference Guide : System Classes : TableField Class
 
Share this page          
TableField Class
The TableField class is a standard table field for displaying the data in an array.
A table field is, by default, associated with an array of the same name. The table field's attributes are referenced using the field function:
field(exampletablefield)
or a reference variable that has been pointed at the table field:
myTf = curframe.TopForm.FieldByFullName(fullname='exampletablefield');
The array is of class ArrayObject, and is referenced by using the name without the field function:
exampletablefield
or by applying the GetFieldValue() method to the table field:
myTf.GetFieldValue(value=Byref(myTfArray));
If you create a table field in Workbench, by grouping fields into a table field, OpenROAD creates a default unnamed class from the data types of the fields grouped together. You can change this default association, adding additional array properties by specifying a class name in the table field's property sheet. Typically, you would use your own created User Class, to allow you to define the attributes you wanted to use. If you create the table field dynamically, you can also set the array variable and its data type dynamically.
A table field displays array data in rows and columns. A row represents one object in the array (one value from each column) and a column represents the set of values in one attribute, across all the rows.
During a drag-and-drop operation, the table row selection remains the same. However, the focus changes—depending on the mouse pointer location—to indicate which row is the drop target. Drag-and-drop also allows multiple row selection. When a user clicks the mouse while the mouse pointer is over a non-selected row, a SELECT event occurs, which enables the user to select multiple rows using the mouse. When a user clicks the mouse while it is over a selected field, a drag-and-drop operation starts. Since row selection does not change, the user can use that information as well.
A table field scrolls during a drag-and-drop operation if the mouse pointer is on the first or last visible row.
For table fields, you should access immediate subcomponents (such as the TableBody and TableHeader StackFields) through the corresponding attributes of the table field:
myTf.TableBody
myTf.TableHeader
However, you will find the ChildFields attribute useful in accessing or stepping through the table's column fields to check or change the cell properties or its displayed value:
myCol = myTf.TableBody.FieldByName(name=myColName);
To access each column of any table field in turn, switching on the HasCellAttributes attribute:
for i = 1 to myTf.TableBody.ChildFields.LastRow do
    myNextCol = myTf.TableBody.ChildFields[i];
    myNextCol.HasCellAttributes = TRUE;
endfor;
To step through every cell of a financial table field (including those cells not currently displayed), examining the value of the corresponding attribute in the corresponding array entry, and highlighting those cells displaying a value greater than 1000:
for i = 1 to myTf.TableBody.ChildFields.LastRow do
    myNextCol = myTf.TableBody.ChildFields[i];
    attributeName = myNextCol.Name;
    for j = 1 to myTfArray.LastRow do
        myTfArray[j].GetAttribute(:attributeName=Byref(value));
        if value > 1000 then
            myNextCol.CellAttribute[j].BgColor = CC_RED;
        endif;
    endfor;
endfor;
For more information about accessing individual cells in a table field, see CellAttribute Class.
For a description of the parts of a table field, with complete syntax descriptions for referencing each part in your 4GL code, and a detailed discussion of dynamically creating a table field, see the chapter "Working with Arrays and Tablefields" in the Programming Guide.
Inherits From
Object Class
FieldObject Class
FormField Class
ActiveField Class
CompositeField Class
Inherited By
None
Attributes
_RowSelected
ActiveRow
AlwaysHighlighted
ColSeparatorColor
ColSeparatorStyle
ColSeparatorWidth
ColumnResizable
ColumnsDisplayed
ControlButton
CurOps
CurRow
Drag_Row
Drop_Row
ExactHeight
ExactWidth
HasHeader
HasHeaderButtons
HasHorizontalScrollBar
HasScrollBar
IsHighlighted
NumVisibleRows
Orientation
QueryOps
ReadOps
RowSeparatorColor
RowSeparatorStyle
RowSeparatorWidth
ScrollingChangesSelection
SelectionType
TableBody
TableHeader
TargetRow
Title
TitleTrim
TopRow
UpdateOps
User1Ops
User2Ops
User3Ops
Methods
CopyToClipboard
DeleteColumn
InsertColumn
SetInputFocus
WhichRow