Kbase 21024: How To Modify Dynamic Browse Column Attributes
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Unverified
GOAL:
How to modify the column attributes of a dynamic browse.
GOAL:
Developers working with a dynamic browse that's generated on the fly using a dynamic query, may wish to change some of the browse columns' setable attributes -- COLOR, FONT, or FORMAT for example.
NOTE: not all column attributes are settable.
FACT(s) (Environment):
Progress 9.X
FIX:
The sample code demonstrates the setting of four column attributes: BGCOLOR and FGCOLOR of the state column, FONT of the Postal-Code column, and the FORMAT of the country column:
These coding steps are used:
1) Define a variable(s) for the handle(s) of the column(s) involved.
2) Assign the value(s) to the column(s) handle(s).
3) Define a ROW-DISPLAY trigger to set the attribute(s) as needed.
/**************************************************/
CURRENT-WINDOW:ROW = 1.
CURRENT-WINDOW:HEIGHT-CHARS = 18.
CURRENT-WINDOW:WIDTH-CHARS = 132.
CURRENT-WINDOW:TITLE = "Dynamic Browse With Dynamic Query".
CURRENT-WINDOW:KEEP-FRAME-Z-ORDER = TRUE.
/* Test controls */
DEFINE BUTTON Make LABEL "CreateDynBrowse".
DEFINE BUTTON AddCols LABEL "Add Columns".
DEFINE BUTTON btn-delete LABEL "DeleteDynBrowse".
DEFINE BUTTON btn-quit LABEL "&Quit" AUTO-ENDKEY.
DEFINE VARIABLE query-criteria AS CHARACTER
VIEW-AS RADIO-SET VERTICAL
RADIO-BUTTONS
"All customers", "FOR EACH customer NO-LOCK", "USA customers",
"FOR EACH customer WHERE customer.country EQ 'USA' NO-LOCK BY customer.state ",
"Non-USA customers",
"FOR EACH customer WHERE customer.country NE 'USA' NO-LOCK BY customer.country "
SIZE 25 BY 3 TOOLTIP "Choose the customers you want to see"
INITIAL "FOR EACH customer NO-LOCK" NO-UNDO.
/* Widget and other Handles */
DEFINE VARIABLE Browse-Hndl AS WIDGET-HANDLE.
DEFINE VARIABLE bufFieldHandle AS WIDGET-HANDLE.
/* add one variable declaration to hold the handle of the column of choice */
DEFINE VARIABLE bchandle AS WIDGET-HANDLE.
DEFINE VARIABLE qh AS WIDGET-HANDLE.
DEFINE VARIABLE bh AS WIDGET-HANDLE.
bh = BUFFER customer:HANDLE.
/* Create Query */
CREATE QUERY qh.
qh:SET-BUFFERS(bh).
DEFINE FRAME F1
skip(13)
make AddCols btn-delete btn-quit query-criteria
WITH SIZE 132 BY 18 THREE-D NO-LABELS.
ON CHOOSE OF make DO: /* LABEL "CreateDynBrowse". */
CREATE BROWSE Browse-Hndl
ASSIGN
FRAME = FRAME F1:HANDLE
QUERY = qh
TITLE = " "
X = 2
Y = 2
WIDTH = 130
DOWN = 12
VISIBLE = TRUE
SENSITIVE = TRUE
READ-ONLY = NO
COLUMN-SCROLLING = TRUE
SEPARATORS = YES.
END.
ON CHOOSE OF AddCols DO: /* LABEL "Add Columns" */
ASSIGN query-criteria.
qh:QUERY-PREPARE(query-criteria).
qh:QUERY-OPEN.
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD(1),1).
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD(3),2).
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("city"),3).
CASE query-criteria:
WHEN "for each customer NO-LOCK" THEN
DO: /* Color the state column */
bchandle = Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("state")).
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("country")).
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("postal-code")).
Browse-Hndl:TITLE = "All Customers".
END.
WHEN "FOR EACH customer WHERE customer.country EQ 'USA' NO-LOCK BY customer.state " THEN
DO: /* Color the postal-code column */
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("state")).
bchandle = Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("postal-code")).
Browse-Hndl:TITLE = "All US Customers".
END.
WHEN "FOR EACH customer WHERE customer.country NE 'USA' NO-LOCK BY customer.country " THEN
DO: /* Color the country column */
bchandle = Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("country")).
Browse-Hndl:ADD-LIKE-COLUMN(bh:BUFFER-FIELD("postal-code")).
Browse-Hndl:TITLE = "Al.l non-US Customers".
END.
END CASE.
/* add the ROW-DISPLAY trigger that will do the coloring */
ON ROW-DISPLAY OF Browse-Hndl
DO:
CASE query-criteria:
WHEN "for each customer NO-LOCK" THEN DO:
bchandle:FGCOLOR = 2.
bchandle:BGCOLOR = 15.
END.
WHEN "FOR EACH customer WHERE customer.country EQ 'USA' NO-LOCK BY customer.state " THEN
bchandle:FONT = 6.
WHEN "FOR EACH customer WHERE customer.country NE 'USA' NO-LOCK BY customer.country " THEN
bchandle:FORMAT = "X(15)":C25.
END CASE.
END.
bufFieldHandle = bh:BUFFER-FIELD("balance").
Browse-Hndl:ADD-LIKE-COLUMN(bufFieldHandle).
AddCols:SENSITIVE = FALSE.
query-criteria:SENSITIVE = FALSE.
make:SENSITIVE = FALSE.
END.
ON CHOOSE OF btn-delete /* LABEL "DeleteDynBrowse". */
DO:
DELETE WIDGET Browse-Hndl.
AddCols:SENSITIVE = TRUE.
query-criteria:SENSITIVE = TRUE.
make:SENSITIVE = TRUE.
END.
ON CHOOSE OF btn-quit
DO:
APPLY "window-close" TO CURRENT-WINDOW.
END.
ENABLE ALL WITH FRAME F1.
WAIT-FOR CLOSE OF CURRENT-WINDOW.
/**************************************************/
.