0

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?

Jensd
  • 7,886
  • 2
  • 28
  • 37
Anburaja
  • 1
  • 1
  • 3

1 Answers1

2

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.
Jensd
  • 7,886
  • 2
  • 28
  • 37