How Do I Control the Initial Focus Within Tab Pages/Grids/Search Pages?

The system automatically places the initial focus on an appropriate widget (generally input fields) within a Tab Page/Search Page/Grid.

By default, focus is placed on the first enabled field that has a data class defined. (Fields with no Field Name / Table Name defined within Meta Data have no data class.)

If there are no fields within the tab page that satisfy this criterion, the system looks recursively into all the contained frames (list grids, for example).

If no field is found then no element receives focus.

You can override the default behavior at each level via the provision of a focusWidgetOverride() function within the user exit file; this returns either the Name of the Field to receive the focus or null.

If null is returned, the system ignores all fields within this document and continues to search in lower-level documents.

For example:

From within a Tab Page (if you want focus to go on to a sub document):


function focusWidgetOverride() {
  return null;
}

From within a List Grid:


function focusWidgetOverride() {
  return "TD_TYPE_DRLKY:0$TBL_NAME";
}

From within a Search Page:


function focusWidgetOverride() {
return "LAST_NAME";
}
Note: These functions can be as simple or complicated as you want. You could conditionally return a field name or null and this code would run each time the window loads. Also, if a tab page has a popup window or a search window open as it is loading, then the initial focus would stay on the popup window, and not on the tab page.