Consultor Eletrônico



Kbase P155791: How to access the focused row of a browse in the browse query when the row is not selected
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/11/2009
Status: Unverified

GOAL:

How to access the focused row of a browse in the browse query when the row is not selected

GOAL:

How to access the currently focused row in a multiple selection browse without selecting the row

GOAL:

Example code using CURSOR-DOWN and CURSOR-UP triggers to access data while navigating a browse

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

Strictly speaking, it is necessary to select a browse row in order to access the corresponding data record in the browse query. It is possible to simulate the effect of having access to the data record of the focused row while navigating the browse by using CURSOR-UP and CURSOR-DOWN triggers to:

Select the focused row.
Use the now selected row to fetch the needed data record.
Use information from the data record to do the desired processing.
Deselect the focused row when processing is finished.
A SCROLL-NOTIFY trigger could be used in a similar way when the user moves through the browse by moving a scrollbar with the mouse.
A typical use case for this technique is to display additional information about the focused row as the user navigates a multiple select browse, to help the user decide whether to select the row.
Example code for a CURSOR-DOWN trigger follows. The CURSOR-UP trigger is similar, except that the GET-NEXT() query method would be replaced with GET-PREV().
DEFINE VARIABLE lOkToDeselect AS LOGICAL NO-UNDO.
/* If the browse row is already selected, do not deselect it at the end. */
IF BROWSE-2:FOCUSED-ROW-SELECTED THEN
lOkToDeselect = FALSE.
ELSE
lOkToDeselect = TRUE.
/* The focused row is still the row we are leaving, not the row we are
moving to. Once we have found it, move down one position in the query. */
BROWSE-2:SELECT-FOCUSED-ROW().
browse-2:QUERY:GET-NEXT().
/* Put the logic using the data record information here. The message below
can be uncommented to show that you have access to the data record. */
/*MESSAGE Order.OrderNum ROWID(Order) VIEW-AS ALERT-BOX.*/
/* Deselect the browse row when you are done, unless it was already
selected. The user can select it again if desired. */
IF lOkToDeselect THEN
BROWSE-2:DESELECT-SELECTED-ROW(BROWSE-2:NUM-SELECTED-ROWS).