Delete browse column

Cringer

ProgressTalk.com Moderator
Staff member
What version of progress? Do you want to delete it at run time or design time?

If it's at run time then I don't think you can actually delete a column, but you can hide it.
 
1) Progress 9.1E
2) Windows XP
3) DEFINE BROWSE br_table-2&ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table-2 V-table-Win _STRUCTURED
QUERY br_table-2 NO-LOCK DISPLAY
ttMargin.range-no COLUMN-LABEL "Range" FORMAT ">9":U WIDTH 12
ttMargin.Amount COLUMN-LABEL "Amount" FORMAT ">>>9.99":U WIDTH 12
ttMargin.TargetMargin COLUMN-LABEL "Margin" FORMAT "->>9.99":U
WIDTH 12
ENABLE
ttMargin.Amount
ttMargin.TargetMargin
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME
WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS MULTIPLE SIZE 41 BY 5 EXPANDABLE.



DEF VAR lhColumn AS WIDGET-HANDLE NO-UNDO.
lhColumn = BROWSE br_table-2:GET-BROWSE-COLUMN( 2 ).
lhColumn:VISIBLE = FALSE.


I have to delete 3rd Column At run time.
 

RealHeavyDude

Well-Known Member
I have never tried to remove a column from a browse. Instead of removing the browse column after it has been resolved at compile time and rendered at rum time I would use a dynamic browse object and add the columns as needed, for example when a user is not entitled to see certain information because of security restrictions.

Heavy Regards, RealHeavyDude.
 

Osborne

Active Member
It is possible to delete a browse column handle but the only way I think this can be achieved is the columns have to be added at run time and you record their handles and actually delete the relevant handle when required. This seems to work:
Code:
DEFINE BUTTON bDeleteCol LABEL "Delete Column 3" SIZE 20 BY 1.

DEFINE VARIABLE vColumnHandles AS HANDLE EXTENT 4 NO-UNDO.

DEFINE QUERY q1 FOR customer SCROLLING.

DEFINE BROWSE b1 WITH SEPARATORS SIZE 69.6 BY 9.91 TITLE "Customer Credit Limits and Balances".

DEFINE FRAME f1
    b1
    bDeleteCol AT ROW 11 COL 26
    WITH SIDE-LABELS ROW 2 CENTERED NO-BOX.

ON CHOOSE OF bDeleteCol IN FRAME f1 DO:
   DELETE OBJECT vColumnHandles[3].
   ASSIGN bDeleteCol:SENSITIVE = FALSE.
END.

b1:QUERY = QUERY q1:HANDLE.

/* Add four columns and record their handles */
vColumnHandles[1] = b1:ADD-LIKE-COLUMN("Customer.custnum").
vColumnHandles[2] = b1:ADD-LIKE-COLUMN("Customer.name").
vColumnHandles[3] = b1:ADD-LIKE-COLUMN("Customer.creditlimit").
vColumnHandles[4] = b1:ADD-LIKE-COLUMN("Customer.balance").
OPEN QUERY q1 FOR EACH customer NO-LOCK.

ENABLE ALL WITH FRAME f1.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
If the columns are part of the browse definition then as Cringer pointed out the only option seems to be to make invisible.
 
I have tried like this:
lhColumn = BROWSE br_table-2:GET-BROWSE-COLUMN(2).
lhColumn:LABEL = "Adjustment".
lhColumn:FORMAT = ">>>999".

But it does change the format of 1st row only.
 

Osborne

Active Member
I think for the format you have to set it for the actual field:

Customer.creditlimit:FORMAT IN BROWSE br_table-2 = ">>>999".
 
I have refined the format in ROW-DISPLAY trigger.
ON ROW-DISPLAY OF br_table-2 IN FRAME F-Main
DO:
ttMargin.Amount:FORMAT IN BROWSE br_table-2 = ">>>999".
END.

It's working fine but when When I try to reset the value in this browse column then it's throwing an error


Invalid use of browse method SCREEN-VALUE. There are no selected rows.
 

Osborne

Active Member
When does the value update take place? It should be okay if in a ROW-DISPLAY:
Code:
ON ROW-DISPLAY OF BROWSE br_table-2 DO:
   ASSIGN ttMargin.Amount:SCREEN-VALUE IN BROWSE br_table-2 = "123456".
END.
If anywhere else, check that a record is available/row is selected first:
Code:
IF AVAILABLE ttMargin /* OR br_table-2:FOCUSED-ROW <> ? */ THEN DO:
   ASSIGN ttMargin.Amount:SCREEN-VALUE IN BROWSE br_table-2 = "123456".
END.
 
Top