Multiple Selection Browse

SteveJBarratt

New Member
There have been many threads about the use of multiple selection browses, however I have never seen a working example posted here.

I am using Progress 9.1D05 on NT.

I have a dynamic query attached to a dynamic browse that is defined as multiple select. I use the normal method of using num-selected-rows and fetch-selected-row(x). I then try to step through the selected rows, but find I have access to the last select row only. I have tried all the examples that I have found on this forum, and I can not get any of them to work. The problem may be my code, I here you say! I have managed to get the multiple select to work by using a static query and a dynamic browse. Is this a bug? Is there a undocumented workaround?

I list below the test code I am 'playing' with, it is not my development program!! The code was modified from a working copy from the progress help screens.

DEFINE VARIABLE browse-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE brws-col-1-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE brws-col-2-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE brws-field-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE buff-field-hdl AS WIDGET-HANDLE.
DEFINE VARIABLE hQuery AS WIDGET-HANDLE.
DEFINE VARIABLE b_ean AS WIDGET-HANDLE.
DEFINE VARIABLE b_ean_attribute AS WIDGET-HANDLE.
DEFINE VARIABLE hbrowse-column1 AS WIDGET-HANDLE.
DEFINE VARIABLE hbrowse-column2 AS WIDGET-HANDLE.
DEFINE VARIABLE hbrowse-column3 AS WIDGET-HANDLE.
DEFINE VARIABLE i AS INTEGER.
DEFINE BUTTON btn-Display LABEL "Display".
DEFINE BUTTON btn-quit LABEL "&Quit" AUTO-ENDKEY.
/* Create handles for buffers for query */
CREATE QUERY hQuery.
CREATE BUFFER b_ean FOR TABLE "ean".
CREATE BUFFER b_ean_attribute FOR TABLE "ean_attribute".
DEFINE FRAME MyFrame SKIP(20) btn-display btn-quit WITH SIZE 80 BY 22.
/* Set up Query */
hQuery:ADD-BUFFER(b_ean).
hQuery:ADD-BUFFER(b_ean_attribute).
hQuery:QUERY-PREPARE("for each ean no-lock, each ean_attribute of ean no-lock").
hQuery:QUERY-OPEN().
/* Set up Browse */
CREATE BROWSE browse-hdl
ASSIGN
MULTIPLE = TRUE
ROW-MARKER = FALSE
FRAME = FRAME MyFrame:HANDLE
QUERY = hQuery
X = 2
Y = 2
WIDTH = 74
DOWN = 20
VISIBLE = YES
SENSITIVE = TRUE
READ-ONLY = NO.
browse-hdl:QUERY = hQuery.
ASSIGN
/* Define columns for browse */
hbrowse-column1 = browse-hdl:ADD-LIKE-COLUMN("ean.ean")
hbrowse-column1:WIDTH-CHAR = 17
hbrowse-column2 = browse-hdl:ADD-LIKE-COLUMN("ean.description")
hbrowse-column2:WIDTH-CHAR = 35
hbrowse-column3 = browse-hdl:ADD-LIKE-COLUMN("ean_attribute.qty-on-hand")
/* allow last column to fill to end of browse */
browse-hdl:EXPANDABLE = YES.
/* Process Display button */
ON CHOOSE OF btn-display DO:

/* set up loop */
DO i = 1 TO browse-hdl:NUM-SELECTED-ROWS:

/* Get each selected row from browse */
browse-hdl:FETCH-SELECTED-ROW(i).

/* Display columns 1 & 2 in a message box */
MESSAGE i hbrowse-column1:SCREEN-VALUE hbrowse-column2:SCREEN-VALUE
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
END.
ON CHOOSE OF btn-quit DO:
QUIT.
END.
ENABLE ALL WITH FRAME MyFrame.
WAIT-FOR CLOSE OF CURRENT-WINDOW.
 
try something like this (static query, static browse) :

Imagine that the browse is displaying fields for the TT_example temp-table :


ON MOUSE-SELECT-DBLCLICK OF {&BROWSE-NAME} IN FRAME {&FRAME-NAME}
DO:

DEF VAR i AS INT NO-UNDO.
DEF VAR n AS INT NO-UNDO.

nb = {&BROWSE-NAME}:NUM-SELECTED-ROWS.

IF nb <> 0 THEN

DO i = 1 TO nb :

IF {&BROWE-NAME}:FETCH-SELECTED-ROW (i) THEN
TT_example.selected = TRUE. /* Or any action needed */
END.

END.


Of course you have to use real name instead of {&ROWSE-NAME} and {&FRAME-NAME} .
 
ref: multiple select browse

Olivier,

I tried your variation, however I do not want to create a temp-table for my browse, because of the number of records involved.

My orginal problem is with dynamic query & browse and to be able to select multiple items using ctrl & mouse or Shift & mouse. Then passing each item to another procedure.

This can be done with static queries & browsers, but I have hit a brick wall with the dyanamic version of my program.

Thank you for your help. I hope someone can shed some more light on to the problem for me.

Regards.

Steve.


Olivier_Desmars said:
try something like this (static query, static browse) :

Imagine that the browse is displaying fields for the TT_example temp-table :


ON MOUSE-SELECT-DBLCLICK OF {&BROWSE-NAME} IN FRAME {&FRAME-NAME}
DO:

DEF VAR i AS INT NO-UNDO.
DEF VAR n AS INT NO-UNDO.

nb = {&BROWSE-NAME}:NUM-SELECTED-ROWS.

IF nb <> 0 THEN

DO i = 1 TO nb :

IF {&BROWE-NAME}:FETCH-SELECTED-ROW (i) THEN
TT_example.selected = TRUE. /* Or any action needed */
END.

END.


Of course you have to use real name instead of {&ROWSE-NAME} and {&FRAME-NAME} .
 
Can I assume that due to the lack of replies that I was right......

There is no way of using a dynamic query with a dynamic browse to use multiple selection, using num-selected-rows and fetch-selected-row(x). ?

I look forward to anyones suggestions on this matter.

Regards.

Steve.
 
Sorry for the long delay....my email has changed and I didn't update my profile in the forum.

I have tried to do multiple selection dynamic browse based on your example above and finally, I have the same problem ! While the NUM-SELECTED-ROWS give the good result, the FETCH-SELECTED-ROW(i) always refers to the same and last row.

Still digging the problem...
 
Oliver,
Thanks for staying with me on this one. I have not given up yet.

I have however, reverted back to a static browse and dynamic query. This works.

I still would like to hear from anyone, whom as got this to work. If anyone else can shed any light on this matter I would appreciate it.
Just for my own intrest.

I'll keep checking this thread each day.

Regards

Steve.
:cool:
 
Hi,

I too have this issue, I will be looking into it myself but if an answer is known I would love to hear it too!

Paul
 
you are displaying values of the colums not values of the buffer who has focus.
Change the code to

MESSAGE ean.ean ean.description
VIEW-AS ALERT-BOX INFO BUTTONS OK.

And you will see it acts as you think it should.

Casper.
 
Back
Top