Page 1 of 1

Showing current record on initial browse in middle of displa

Posted: Mon Sep 17, 2012 11:59 am
by Cliff Wiernik
If you happen to be at or near the end of the logical ordering of records in a browse, when you initially display the browse, that record happens to be at the end of the browse. If there are more records above the current record point, I would like to display the initial browse so that the current record appears in the middle of the browse data area. I would like to have the record point still remain on the current record. That way you can see some of the records above and below the current record are displayed.

Is there an easy way to do this.

Cliff.

Re: Showing current record on initial browse in middle of di

Posted: Mon Sep 17, 2012 3:53 pm
by rdonnay
This test program works pretty good for me.

Code: Select all

#INCLUDE "dcdialog.CH"

FUNCTION Main()

LOCAL GetList[0], GetOptions, oBrowse

USE \exp19\data\xtest

GO 500

@ 0,0 DCBROWSE oBrowse ALIAS 'XTEST' SIZE 50,20 FIT ;
   FONT '10.Lucida Console'

DCBROWSECOL DATA {||XTEST->(RecNo())} HEADER 'Record' WIDTH 6 PARENT oBrowse PICTURE '99999'
DCBROWSECOL FIELD XTEST->exchange HEADER 'Exch' WIDTH 4 PARENT oBrowse
DCBROWSECOL FIELD XTEST->areacode HEADER 'Area' WIDTH 4 PARENT oBrowse
DCBROWSECOL FIELD XTEST->number HEADER 'Number' WIDTH 4 PARENT oBrowse
DCBROWSECOL FIELD XTEST->city HEADER 'City' WIDTH 30 PARENT oBrowse

DCREAD GUI FIT TITLE 'Browse Test' EVAL {||AdjustRow(oBrowse)}

RETURN nil

* ----------

PROC appsys ; return

* ----------

FUNCTION AdjustRow( oBrowse )

LOCAL nSaveRec, i

nSaveRec := (oBrowse:dataSource)->(RecNo())

oBrowse:goBottom()
oBrowse:forceStable()
FOR i := 1 TO oBrowse:rowCount/2
  oBrowse:up()
NEXT
oBrowse:forceStable()
(oBrowse:dataSource)->(dbGoto(nSaveRec))
oBrowse:refreshAll()

RETURN nil

Re: Showing current record on initial browse in middle of di

Posted: Tue Sep 18, 2012 11:39 am
by Cliff Wiernik
Thanks. Works like a charm. Didn't think about using :forcestable().

See you at the Dev Con. Arriving on Wednesday.

Cliff

Re: Showing current record on initial browse in middle of di

Posted: Wed Sep 19, 2012 7:12 am
by rdonnay
I'm glad it worked for you.

See you next month.

Re: Showing current record on initial browse in middle of di

Posted: Wed Sep 19, 2012 9:26 am
by Cliff Wiernik
Had to modify it a bit when you had a small number of records, it was not staying on the original record. But you gave me the right direction.

Cliff.