Consultor Eletrônico



Kbase P67140: How to set highlightWidget based on user selection
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/02/2004
Status: Unverified

GOAL:

How to set highlightWidget based on user selection

GOAL:

When using a browser in Dynamics the highlightWidget API is very useful to set the color scheme of a cell in the browse however there may be some management of the colored cell required to ensure the behavior is as expected.
A typical use of this API would be to put the call to API in the rowdisplay of the browse and set the value based on the data in the row. For example, if the browse has num field and a name then the code may set the color for all rows where the name begins with the letter "S".
However, there may be cases where the rule to set the API is based purely on, eg. the user selecting the cell and firing a trigger to set the color, in which case the rowdisplay procedure needs to have coding done to ensure the behavior of the colored cell is as expected. If this code is not applied then the call will simply be colored as required but on moving the row out/in of the browse viewport then the color setting will be lost.

FIX:

Many ways to resolve this but as an example:
Assume a container with a viewer, browser and sdo - the viewer has a button which allows the user to change the color of a cell in the current row, when the button is chosen:
1. Run the procedure defined against the button in the viewer's super procedure
2. In the viewer's super procedure get the handle to the browser
3. Using widgetvalue, get the record being selected, either from the viewer if based on the same table or from the browser itself, for example widgetvalue("myfullb.name")
3. Run a procedure (eg. 'test') in the browser handle, inputting the widgetvalue
4. In the super procedure of the browser, create a temp-table with one character field in the definitions section (just so rowdisplay can also access it) and then create a procedure 'test' that takes in the passed widgetvalue.
5. In 'test', create a temp-table record and assign the character field to be the input widgetvalue then issue a call to RUN rowdisplay IN TARGET-PROCEDURE
6. In the rowdisplay procedure check if the temp table record matches the current row, eg.
FIND FIRST mytt WHERE mytt.f1 = widgetvalue("name") NO-ERROR.
IF AVAILABLE(mytt) THEN highlightwidget("name", "error").
ELSE highlightwidget("name", "warn").

This results in the selected row's cell being changed as required and, if more cells are selected, they are also highlighted. In addition, if the selected cells move inout/in of the viewport the color changes remain visible.