Repostion after brows:SELECT-ALL

davidvilla

Member
Hi,
After a "mybrowse:SELECT-ALL() IN FRAME myframe." statement on a multi-select browse, the focus automatically repositions to the first record. Can I retain the focus to the same row in the browse that was focused before the execution of the SELECT-ALL statement, without doing a reposition by storing the row-id? The browse records (i.e., the position of the rows and the focus should remain as such and only the selection ('>') should happen. How can I achieve this? :confused:

I m using CHUI in version 10.1B.
 
AFAIK no. Whenever you select a row in the browser the query gets repositioned. The browse widget and the query behind it are directly tied together via the browse widget's query attribute. Therefore, depending on your selection, the query will be repositioned to a different row than it was before the selection. The only way I am aware of to work around this is what you already describe.

What's wrong with that solution?

Heavy Regards, RealHeavyDude.
 
You're welcome.

Back at the beginning of the '90s when I was introduced to the Progress 4GL I was very impressed with what statement the trainer opened the first training session: We want to have it easy.

Sometimes it's just not so easy to live up to it ...


Heavy Regards, RealHeavyDude.
 
Is there anything easier than this?

iCurFocussedRow = mybrowse:FOCUSED-ROW.
mybrowse:SELECT-ROW(1).
rCurFirstRowId = ROWID(mytemptable).
mybrowse:SELECT-ALL() IN FRAME myframe.
REPOSITION myquery TO ROWID rCurFirstRowId.
DO iCntr = 1 TO (iCurFocussedRow - 1):
APPLY 'Cursor-down':U TO mybrowse IN FRAME myframe.
END.
 
Try this:
Code:
iCurFocussedRow = mybrowse:FOCUSED-ROW.
[COLOR=Silver]/* mybrowse:SELECT-ROW(1). */[/COLOR]  [COLOR=Red]/* This selects first row in viewport, not the one focused */[/COLOR] 
[COLOR=DarkGreen]mybrowse:SELECT-FOCUSED-ROW(). [/COLOR][COLOR=Red]/* */[/COLOR] 

rCurFirstRowId = ROWID(mytemptable).
mybrowse:SELECT-ALL() IN FRAME myframe.

[COLOR=DarkGreen]mybrowse:SET-REPOSITIONED-ROW(iCurFocussedRow, "always").[/COLOR]  [COLOR=Red]/* use this instead of apply 'cursor-down' ... */[/COLOR]
REPOSITION myquery TO ROWID rCurFirstRowId.
[COLOR=DarkGreen]mybrowse:SET-REPOSITIONED-ROW(1, "always"). [/COLOR][COLOR=Red]/* */[/COLOR] 

[COLOR=Gray]/*
DO iCntr = 1 TO (iCurFocussedRow - 1):
        APPLY 'Cursor-down':U TO mybrowse IN FRAME myframe.
END.                 
*/[/COLOR]
 
This is what I have done.

iCurFocussedRow = mybrowse:FOCUSED-ROW. /* gets the row number of the current focused row */

mybrowse:SELECT-ROW(1). /* selects the first row in the view port */
rCurFirstRowId = ROWID(mytemptable). /* store the rowid of the first record in the view port */

mybrowse:SELECT-ALL() IN FRAME myframe.

REPOSITION myquery TO ROWID rCurFirstRowId. /* Reposition to the row that was the first row in the browse's view port before the SELECT-ALL operation. Now this row will be focused. */

/* Navigate to the row that was focused before the SELECT-ALL operation */
DO iCntr = 1 TO (iCurFocussedRow - 1):
APPLY 'Cursor-down':U TO mybrowse IN FRAME myframe.
END.


By this way, the view-port remains the same before and after the SELECT-ALL operation.

Now my worry is that can I do it without selecting the first row in the view-port. I mean, I need to get the rowid of the first record in the view-port without selecting or focusing it. How can I do this?:confused:
 
AFAIK the SELECT-ROW does two things: It repositions the query associated with the browse widget and in the process transferring the contents of the record into the record buffer. Plus, it transfers the contents of the record buffer into the screen buffer ( the SCREEN-VALUE attributes of the browse cells ). To retrieve the ROWID of a record displayed in the view-port of the browse widget you either need to access the ROWID associated with the record buffer or you could display the rowid ( formatted as string as a hidden column ) and access the screen-value of the corresponding browse cell. But, just having the ROWID, are you able to decide whether the ROWID belongs to the record you need? I think you need to retrieve the record anyway in order to decide if it's the record you want.

Therefore I think there is no better way than using SELECT-ROW and probably DESELECT-ROW in order to achieve what you want to achieve. So why the worry?

Heavy Regards, RealHeavyDude.
 
After the SELECT-ROW, I am not sure, which row to DESELECT, because there are many other rows that are selected in the browse. Can I deselect based on row-id?
 
Back
Top