I've used a BROWSE widget to display search results in. The search based on one of several available fields in a TEMP-TABLE.
What I want to do is to dynamically set the format of the matching field to "x(16)" instead of "x(11)". The matching field name is stored within a variable.
The example below is a static browse where the search is based on "desc1", I want to make it dynamic so that it can be used to display results regardless of matching field.
DEFINE BROWSE brResults
QUERY qResults
DISPLAY
ttRowsmaj.desc1 FORMAT "x(16)" COLUMN-LABEL "Desc 1"
ttRowsmaj.desc2 FORMAT "x(11)" COLUMN-LABEL "Desc 2"
ttRowsmaj.desc3 FORMAT "x(11)" COLUMN-LABEL "Desc 3"
ttRowsmaj.desc4 FORMAT "x(11)" COLUMN-LABEL "Desc 4"
ttRowsmaj.desc5 FORMAT "x(11)" COLUMN-LABEL "Desc 5"
WITH 11 DOWN MULTIPLE NO-BOX.
Can anyone help me do that?
You can set the format of the buffer field like this:
ttRowsmaj.desc3:FORMAT IN BROWSE brResults = "x(16)".
But it will only change the DISPLAY format, not the width of the column. To set the width you do:
ttRowsmaj.desc3:WIDTH IN BROWSE brResults = 20.
or a more dynamic approach:
DEFINE VARIABLE iCol AS INTEGER NO-UNDO.
DEFINE VARIABLE cSearchField AS CHARACTER NO-UNDO.
/* Assuming search-field was "desc4" */
ASSIGN
cSearchField = "desc4".
/* Go through all columns */
DO iCol = 1 TO BROWSE brResults:NUM-COLUMNS.
/* If column name matches serch*/
IF BROWSE brResults:GET-BROWSE-COLUMN(iCol):NAME = cSearchField THEN DO:
/* Set format & width */
BROWSE brResults:GET-BROWSE-COLUMN(iCol):FORMAT = "X(16)".
BROWSE brResults:GET-BROWSE-COLUMN(iCol):WIDTH = 25.
END.
END.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.