Ask Reuben

Table Column Titles

Do I need to have table column titles? 

How are table column titles determined? 

Where are table column titles used? 

How do I change table column titles at run-time? 

How can I wrap long table column titles over two or more lines?

I recently saw a case that arose because a table did not have any table column titles defined.  Whilst it is not mandatory for a table column to have a title, I would say it is highly recommended.  That is because they are also used …

  • in the built-in find window to allow you to restrict the find search to a nominated column, this dropdown of a list of available columns is populated using the table column title attribute.




So unless you customised the built-in find window so it did not allow you to restrict the search to a specific column, and you used the UNHIDABLECOLUMNS / UNHIDABLE attribute to not allow the user to show/hide columns, it is likely that you are going to want to specify a table column to have a title so that these areas of functionality allow you to identify the table column.

There are three ways you can specify a title for a table column.

  1. The first was designed to minimise the effort in transforming code from Informix-4gl to Genero.  In the .per, where you have columns in a table, the form compiler had some logic built into it to try and assign any text found in the one line above the repeating item tags as the title of each column.   There was some logic built into this process so that if it found two words separated by a space it would treat that as one title.  Using “+” to represent space,  “Account+Code” would be treated as one column title,  whilst “Account++Code” the form compiler would treat as two potential column titles “Account” and “Code”.  Using the code below, notice the column titles in the screenshot…

LAYOUT
TABLE
{
 Account Code   Account  Code      
[f01           |f02     |f03       ]
}
END
END
ATTRIBUTES
EDIT f01 = formonly.field1;
EDIT f02 = formonly.field2;
EDIT f03 = formonly.field3;

INSTRUCTIONS
SCREEN RECORD scr(field1, field2, field3)


  1. The second technique was to use the TITLE attribute in the form and assign a title to each individual column in the attributes section of the form.  (For Genero Studio users there is a property title for each table column).  This techniques has some advantages in that
    • you can use localization by setting the TITLE to a localized string e.g. TITLE=%"account.code"
    • you can have column titles that flow over multiple lines.  Simply use \n to indicate the line break e.g. TITLE="Account\nCode".  (the line break is replaced by a space when the column title is used elsewhere)

From a coding standards point of view, this technique is also the best at enforcing a mandatory column header as it is easy to test if the TITLE attribute is defined or not.

The code sample below produces the following output, note how the 3rd column title wraps over two lines …

LAYOUT
TABLE
{
[f01       |f02       |f03       ]
}
END
END
ATTRIBUTES
EDIT f01 = formonly.field1, TITLE="Account Code";
EDIT f02 = formonly.field2, TITLE=%"account.code";
EDIT f03 = formonly.field3, TITLE="Account\nCode";

INSTRUCTIONS
SCREEN RECORD scr(field1, field2, field3)

  1. The third technique is to use the ui.Form.setElementText method to change the title of column headers.  This technique is useful if you
    • maintain column titles in a database and allow the end-user or your business analysts to configure them without requiring a form compilation.
    • change column titles at run-time
    • allows you to define column titles via a function call or via use of SFMT.  For instance, CALL f.setElementText("fieldname", SFMT("LastYear\n(%1)", last_year)“.

The above screenshots could have had their column titles defined with code of the nature …

DEFINE f ui.Form
...
CALL f.setElementText("formonly.field1", "Account Code")
CALL f.setElementText("formonly.field2", %"account.code")
CALL f.setElementText("formonly.field3", "Account\nCode")

# as well as using functions or SFMT
CALL f.setElementText("formonly.field4", get_title("account.code"))
CALL f.setElementText("formonly.field5", SFMT("%1\n%2","Account","Code"))

If you do have forms that do not have column titles defined, I would suggest you review your code and verify that you are happy with what appears in the built-in find window, or when you right-click in the table header.  Note the different techniques you can use to define a column title and make sure you have a coding standard covering when it is appropriate (if at all) to use the different techniques.

Finally, on subject of table column titles, a reminder of the second Ask-Reuben article which covered how you can better align column headers with the content of the column.