How to get selected row in Browse

Ram Prashanth

New Member
I have a dialog box which has a browse with some data in it.
How to get the value of selected row in that browse on choose of a button outside the browse. I am not able to access rowobject of browse.
I tried to use col values,
Code:
DYNAMIC-FUNCTION('colValues' IN h_sdb_salesrep, rowobject.salesrep)
but i was not able to succeed. Can anyone help me how to achieve this.

Thanks,
Ram.
 

Osborne

Active Member
Is the button in a completely different procedure to the browse and thus does not know anything about the browse? So you cannot do something like this to see if a row is selected in the button trigger?:

Code:
message browse brws:focused-row browse brws:num-selected-rows view-as alert-box.

If this is the problem then do you have a handle to the browse or a handle to the table in the browse? Knowing these you could loop through the columns and get the values that way:

Code:
DEFINE VARIABLE vCount AS INTEGER NO-UNDO.
DEFINE VARIABLE hColumn AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.

DO vCount = 1 TO hBrowse:NUM-COLUMNS:
   ASSIGN hColumn = hBrowse:GET-BROWSE-COLUMN(vCount)
          hField = hBuffer:BUFFER-FIELD(hColumn:NAME).
   MESSAGE hField:BUFFER-VALUE() VIEW-AS ALERT-BOX.
END.
 

Ram Prashanth

New Member
Is the button in a completely different procedure to the browse and thus does not know anything about the browse? So you cannot do something like this to see if a row is selected in the button trigger?:

Code:
message browse brws:focused-row browse brws:num-selected-rows view-as alert-box.

If this is the problem then do you have a handle to the browse or a handle to the table in the browse? Knowing these you could loop through the columns and get the values that way:

Code:
DEFINE VARIABLE vCount AS INTEGER NO-UNDO.
DEFINE VARIABLE hColumn AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.

DO vCount = 1 TO hBrowse:NUM-COLUMNS:
   ASSIGN hColumn = hBrowse:GET-BROWSE-COLUMN(vCount)
          hField = hBuffer:BUFFER-FIELD(hColumn:NAME).
   MESSAGE hField:BUFFER-VALUE() VIEW-AS ALERT-BOX.
END.
I have both the browse and a button inside a smart dialog, Is it not possible to access selected row of browse on clicking the button.
 

Osborne

Active Member
Is the browse a smart browse and if so then unfortunately I do not know as not used smart objects? For a standard browse you can access a selected row using something like this:

Code:
IF Brws:NUM-ITERATIONS <> 0 THEN Brws:SELECT-FOCUSED-ROW().
 

Ram Prashanth

New Member
Is the browse a smart browse and if so then unfortunately I do not know as not used smart objects? For a standard browse you can access a selected row using something like this:

Code:
IF Brws:NUM-ITERATIONS <> 0 THEN Brws:SELECT-FOCUSED-ROW().
Yes it is a smart browse
 

Osborne

Active Member
Yes it is a smart browse

Never used a smart browser so unfortunately do not know.

It seems a similar question has been asked before but unfortunately no code example was given:


Are you able to work it out from the code examples in these postings?:

 
Top