Page 1 of 1

xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 9:45 am
by PeterHarmes
Hi,

I have an xbrowse looking at records in a database. This database can be viewed and edited by multiple users.

If a record is deleted by another user the browse can look corrupt containing duplicate records.

The way i'm trying to fix this is to refresh the browse after i perform any actions within the browse, something like this:

Save current record number
Perform action
Recreate scope & filter
Goto saved record number
Refresh browse

This works ok, but the selected record is positioned at the top of the browse. Is there any way that i can remember the position of the highlight bar, refresh and return the highlight bar to its original position?

I have tried using oBrw:nRowSel but havent had much luck

Any ideas?

Best regards,

Pete

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 10:21 am
by nageswaragunupudi
I have tried using oBrw:nRowSel but havent had much luck

This is the right way.
Save and restore oBrw:nRowSel and call Refresh()

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 10:37 am
by PeterHarmes
That works perfectly

Thanks for your time

best regards,

Pete

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 1:20 pm
by carlos vargas
please rao, can put a example.

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 1:31 pm
by Rick Lipkin
Peter and Rao

I have been fighting this very same problem only instead of using .dbf I have been using recordsets.

I set up a test where I had the same app open twice and the first app deleted a row and I tried to trap the second app from trying to delete the same row since to app 2 his recordset still had the 'deleted' record buffered and displayed.

What I did was in the delete routine .. I stored the unique row id of the record to be deleted .. did a oRs:Requery() to refresh the 'current' data .. did a oRs:Find on the ( row id and if oRs:eof ( or not found ) .. showed an alert the row was missing and issued a oBrw:Refresh().

Where I got into trouble was issuing both oBrw:Refresh() and a SysRefresh() and I got all kinds of run time errors. By accident .. I removed the SysReFresh() and xBrowse re-painted correctly eliminating the previously deleted row.

Like Rao mentions .. just issue a oBrw:ReFresh() and xBrowse will re-adjust and display the current records ( added, edited or deleted ) properly.

Rick Lipkin

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 1:32 pm
by PeterHarmes
This is my code:

Code: Select all  Expand view


nSavRec := ORDERS->(Recno())
nSavRow := oBrw:nRowSel
//Apply Scope and filter
SetSchedFilter(.T.)
ORDERS->(DbGoto( nSavRec ))
IF ORDERS->OR_TICKNBR > 0   //Record Exists
    oBrw:nRowSel := nSavRow 
ELSE
    oBrw:Gotop()
ENDIF
oBrw:Refresh()
 

Re: xBrowse Refreshing

PostPosted: Fri Sep 30, 2011 1:42 pm
by PeterHarmes
Rick,

My problem was due to a SysRefresh() being in my browse refresh routine.

The only problem I have now is if a record is deleted on another machine and the user scrolls up using the up/down arrow when it comes to the deleted record, a duplicate row appears - page up/page down refreshes as well as my refresh routine.

Regards,

Pete