Progress
Programming
Handbook


Creating Dynamic Browse Columns

The dynamic browse that you create with the CREATE BROWSE statement is an empty browse. You must add the browse columns using the following methods:

ADD–COLUMNS–FROM( ) Method

The ADD–COLUMNS–FROM( ) method creates a browse column for every field in the specified table or buffer except for any fields specified in an except-list. The specified table or buffer must be in the associated query. Use this method when you want the browse to contain all or most of the fields in a table or buffer.

The following program creates a browse which displays all the fields in the customer table except for terms and comments:

p-dybrw1.p 
DEFINE VARIABLE b1 AS HANDLE.
DEFINE QUERY q1 FOR customer EXCEPT (terms comments) SCROLLING.
OPEN QUERY q1 FOR EACH customer WHERE customer.cust-num < 10.

DEFINE FRAME f1
    WITH SIZE 82 BY 29.

CREATE BROWSE b1
    ASSIGN
      FRAME = FRAME f1:HANDLE
      X = 2
      Y = 2
      WIDTH = 80
      DOWN = 10
      QUERY = QUERY q1:HANDLE
      TITLE = "Dynamic Browse with static query"
      SENSITIVE = TRUE
      VISIBLE = TRUE
      READ-ONLY = FALSE
      SEPARATORS = TRUE.

b1:ADD-COLUMNS-FROM("customer","terms,comments").

ENABLE ALL WITH FRAME f1.
WAIT-FOR CLOSE OF CURRENT-WINDOW. 

ADD–LIKE–COLUMN( ) Method

The ADD–LIKE–COLUMN method creates a single browse column from the specified field name or buffer field handle. You can also define the position of this column within the browse. The specified field must be a field in one of the buffers of the associated query. Use this method when you want the browse to contain only a few fields in a table or buffer.

The following program creates a browse containing only four fields from the customer table:

p-dybrw2.p 
DEFINE VARIABLE b1 AS HANDLE.
DEFINE QUERY q1 FOR customer
        FIELDS (cust-num name phone contact) SCROLLING.
OPEN QUERY q1 FOR EACH customer WHERE customer.cust-num < 10.

DEFINE FRAME f1
    WITH SIZE 82 BY 29.

CREATE BROWSE b1
    ASSIGN
      FRAME = FRAME f1:HANDLE
      X = 2
      Y = 2
      WIDTH = 80
      DOWN = 10
      QUERY = QUERY q1:HANDLE
      TITLE = "Dynamic Browse with static query"
      SENSITIVE = TRUE
      VISIBLE = TRUE
      READ-ONLY = FALSE
      SEPARATORS = TRUE.

b1:ADD-LIKE-COLUMN("customer.cust-num").
b1:ADD-LIKE-COLUMN("customer.name").
b1:ADD-LIKE-COLUMN("customer.phone").
b1:ADD-LIKE-COLUMN("customer.contact").

ENABLE ALL WITH FRAME f1.
WAIT-FOR CLOSE OF CURRENT-WINDOW. 

For other examples of the ADD–LIKE–COLUMN( ) method, see the program, p-fnlqry.p, in section "Dynamic Query Code Example."

ADD–CALC–COLUMN( ) Method

The ADD–CALC–COLUMN( ) method creates a single browse column with the specified properties rather than from a table or buffer field. This is typically used as a placeholder column for a calculated value.

The following program creates a browse containing four fields from the customer table plus a fifth field containing the calculated current credit limit:

p-dybrw3.p 
DEFINE VARIABLE b1 AS HANDLE.
DEFINE VARIABLE calch AS HANDLE.

DEFINE QUERY q1 FOR customer
     FIELDS (cust-num name phone contact credit-limit balance) SCROLLING.
OPEN QUERY q1 FOR EACH customer WHERE customer.cust-num < 30.

DEFINE FRAME f1
    WITH SIZE 78 BY 18.

CREATE BROWSE b1
    ASSIGN
      FRAME = FRAME f1:HANDLE
      X = 2
      Y = 2
      WIDTH = 76
      DOWN = 15
      QUERY = QUERY q1:HANDLE
      TITLE = "Dynamic Browse with static query"
      SENSITIVE = TRUE
      VISIBLE = FALSE
      READ-ONLY = FALSE
      SEPARATORS = TRUE.

ON ROW-DISPLAY OF b1 DO:
    IF VALID-HANDLE(calch) THEN
      calch:SCREEN-VALUE=STRING(customer.credit-limit - customer.balance).
END.

b1:ADD-LIKE-COLUMN("customer.cust-num").
b1:ADD-LIKE-COLUMN("customer.name").
b1:ADD-LIKE-COLUMN("customer.phone").
b1:ADD-LIKE-COLUMN("customer.contact").
calch=b1:ADD-CALC-COLUMN("DECIMAL","->,>>>,>>9.99","0","CurrentLimit").

b1:VISIBLE = TRUE.

ENABLE ALL WITH FRAME f1.
WAIT-FOR CLOSE OF CURRENT-WINDOW. 

Notes on Dynamic Browse Columns

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095