Fetching Selected Records in Brw

Kladkul

Member
I'm having issues with a multi-selection browse I'm developing.

The browse is displaying a query from a temp-table that is created earlier in the program. The issue I'm having is how to find out what the user has selected.

I've played around with several different triggers and still can't find the best method for determining the records that were selected. Any help?
 

Casper

ProgressTalk.com Moderator
Staff member
loop through num-selected-rows to find the records which are selected in the browse. Use fetch-selected-row(n) to fetch then n-th selected row in the browse.

Casper.
 

lord_icon

Member
Try looking at this attribute:

{&BROWSE-NAME}:FOCUSED-ROW

Then you can get the widget row number, to get the handle for the displayed database row
 

Kladkul

Member
Here is what I tried for the looping idea:

Code:
  DO v-cnt = 1 TO brw-deploy:NUM-SELECTED-ROWS:      
      MESSAGE brw-deploy:FETCH-SELECTED-ROW(v-cnt)
          VIEW-AS ALERT-BOX INFO BUTTONS OK.
  END.
I used MESSAGE just to see if anything was returned and it returned "yes" everytime. How do I get the data that was actually selected?
 

jmac12

Member
I'm Having the same issue I'm using progress 9.1c, FETCH-SELECTED-ROW returns a bool thats why you are just getting yes. But I'm not sure where to look for the row index/row id? So I can actual know what record I'm looking at
 

LarryD

Active Member
You can try this:

Code:
    def var v-tmp as logical no-undo.
    def var record-id as recid no-undo. 
    do i = 1 to brwsname:num-selected-rows:
        v-tmp = brwsname:fetch-selected-row(i).
        if v-tmp then do:
            record-id = recid(mytable).
            find mytable no-lock where recid(mytable) = record-id no-error.
            .... stuff ....
       end.  /* of v-tmp true */
    end.  /* of do i */

Technically I don't think you need to do the recid since I believe the record is in the buffer (and others can correct me if I'm wrong), but if you want to do anything to it then you can do the recid and find exclusive-lock or whatever.
 

jmac12

Member
Right think I've got it :
DO iRow = 1 TO br_search:NUM-SELECTED-ROWS:

MESSAGE br_search:FETCH-SELECTED-ROW ( iRow ).
MESSAGE a-chd.kcode. /*field in table*/

END.

you get the row then its looking at the correct record, I need to test it but looks good to me
 

Casper

ProgressTalk.com Moderator
Staff member
record-id = recid(mytable).
find mytable no-lock where recid(mytable) = record-id no-error.

Don't overcomplicate it. Why would you use a recid of a table which is in the record buffer to find the same table?

After the fetch-selected-row(n) the record is in scope and you can do anything with it as you like.

Casper.
 
Top