TABLE container

Defines a re-sizable table designed to display a list of database records.

Syntax

TABLE [identifier] [ ( attribute [,...] ) ]
{
 title [...]
[col-name   [|...]     ]
[...]
[aggr-name  [|...]     ]
}  
END
  1. identifier defines the name of the element.
  2. attribute is an attribute for the element.
  3. title is the text to be displayed as column title.
  4. col-name is an identifier that references a form field.
  5. aggr-name is an identifier that references an aggregate Field.

Attributes

AGGREGATETEXT, COMMENT, DOUBLECLICK, HIDDEN, FONTPITCH, STYLE, TAG, UNHIDABLECOLUMNS, UNMOVABLECOLUMNS, UNSIZABLECOLUMNS, UNSORTABLECOLUMNS, WANTFIXEDPAGESIZE, WIDTH, HEIGHT.

Usage:

The TABLE container defines the presentation of a list of records, bound to a screen array.

To create a table view, you must define the following elements in the form file:

  1. The layout of the list, with a TABLE container in the LAYOUT section.
  2. The column data types and field properties, in the ATTRIBUTES section.
  3. The field list definition to group form fields together with a screen array, in the INSTRUCTIONS section.

When using this layout container with curly braces, the position of the static labels and item tags is automatically detected by the form compiler to build a graphical object displaying a list of records. Column titles for the table list can be defined in the table layout, or as attributes in the definition of the form fields that make up the table columns.

The default width and height of a table are defined respectively by the columns and the number of lines used in the table layout. You can overwrite the defaults by specifying the WIDTH and HEIGHT attributes, as in this example:
TABLE t1 ( WIDTH = 5 COLUMNS, HEIGHT = 10 LINES )
You design the TABLE rows within curly braces. The columns are defined with item tags and form fields. Every column tag must be properly aligned. You typically use a pipe character to separate the column tags:
TABLE
{
[column1    |column2              |column3               ]
[column1    |column2              |column3               ]
[column1    |column2              |column3               ]
}
END

Avoid Tab characters (ASCII 9) inside the curly-brace delimited area. If used, Tab characters will be replaced by 8 blanks byfglform.

The TABLE layout definition can contain column titles as well as the tag identifiers for each column's form fields. The fglform form compiler can associate column titles in the table layout with the form field columns if they are aligned properly. Note however that at least two spaces are required between column titles:
TABLE
{
 Title1      Title2                Title3
[column1    |column2              |column3               ]
[column1    |column2              |column3               ]
[column1    |column2              |column3               ]
}
END
As an alternative, you can set the column titles of a table container by using the TITLE attribute in the definition of the form fields, instead of using column header text in the table layout. This allows you to use localized strings for the column titles:
TABLE
{
 [c1  |c2          |c3         ]
 [c1  |c2          |c3         ]
 [c1  |c2          |c3         ]
}
END
...
ATTRIBUTES
EDIT c1 = FORMONLY.col1, TITLE=%"Num";
LABEL c2 = FORMONLY.col2, TITLE=%"Name";
CHECKBOX c3 = FORMONLY.col3, TITLE=%"Status",
                VALUECHECKED="Y", VALUEUNCHECKED="N";
 ...
The height of table columns can be defined by adding empty tags underneath column tags (this makes sense only when using widgets that can get a height such as TEXTEDIT or IMAGE):
TABLE
{
 Title1      Title2                Title3
[column1    |column2              |column3               ]
[           |                     |                      ]
[column1    |column2              |column3               ]
[           |                     |                      ]
[column1    |column2              |column3               ]
[           |                     |                      ]
}
END
A table container is bound to a screen array defined in the INSTRUCTION section, by the name of the form fields used in the screen array definition.
The column data type and additional properties are defined in the ATTRIBUTES section, as form fields:
ATTRIBUTES
EDIT column1 = customer.cust_num;
EDIT column2 = customer.cust_name, 
EDIT column3 = customer.cust_cdate;
Each form field of the table must be grouped in the INSTRUCTIONS section in a screen record definition:
SCREEN RECORD listarr( col1, col2, col3 )
The screen record identifies the record list in programs when you use an INPUT ARRAY or DISPLAY ARRAY instruction:
INPUT ARRAY custarr FROM listarr.*

The screen array members must match the program array record members: These will be bound by position in DISPLAY ARRAY or INPUT ARRAY. Therefore, the order of the screen array elements matters. However, the position of the TABLE columns can be different from the members of the screen array and program array. So the program array can be defined from the database table definition with the DEFINE LIKE instruction. Further, if you want to omit columns in the TABLE layout, define the these columns as PHANTOM fields, to include them in the definition of the screen array.

By default, the current row in a TABLE is highlighted in display mode (DISPLAY ARRAY), but it is not highlighted in input mode (INPUT ARRAY, CONSTRUCT). You can set decoration attributes of a table with a presentation style of the Table class.

AGGREGATE fields can be added at the end of the TABLE layout, to get a summary line in the list. When aggregate fields are defined in the table, a summary line will be displayed:
TABLE
{
 [c1  |c2          |c3         ]
 [c1  |c2          |c3         ]
                   [total      ]
}
END
...
ATTRIBUTES
...
AGGREGATE total = FORMONLY.total, AGGREGATETYPE=PROGRAM;
...

You can specify the AGGREGATETEXT attribute at the TABLE level, to get a global label for the summary line. The aggregate label will appear on the left in the summary line, if no aggregate text is defined at the aggregate field level. Use presentation style attributes to decorate the summary line.

By default, tables can be re-sized in height. Use the WANTFIXEDPAGESIZE attribute to deny table resizing.

With the DOUBLECLICK attribute, you can define a particular action to be sent when the user double-clicks on a row.

By default, a table allows to hide, move, resize columns and sort the list when the user clicks on a column header. The UNHIDABLECOLUMNS, UNMOVABLECOLUMNS, UNSIZABLECOLUMNS, UNSORTABLECOLUMNS attributes can be used to deny these features.

After a dialog execution, the current row may be deselected, depending on the KEEP CURRENT ROW dialog attribute.

SCHEMA videolab 
LAYOUT ( TEXT="Customer list" )
TABLE ( TAG="normal" )
{
 [c1     |c2                        |c3        |c4 ]
 [c1     |c2                        |c3        |c4 ]
 [c1     |c2                        |c3        |c4 ]
 [c1     |c2                        |c3        |c4 ]
}
END
END
TABLES
  customer 
END
ATTRIBUTES
  EDIT c1 = customer.cust_num, TITLE="Num";
  EDIT c2 = customer.cust_name, TITLE="Customer name";
  EDIT c3 = customer.cust_cdate, TITLE="Date";
  CHECKBOX c4 = customer.cust_status, TITLE="Status";
END
INSTRUCTIONS
  SCREEN RECORD custlist( cust_num, cust_name, cust_cdate, cust_status )
END