by ellano » Sat Sep 26, 2009 11:17 am
Ok. Here is the final code when doing a synchronized search in an array and database (now fully working)
Clean_Areas()
SELECT sales
SET ORDER TO TAG "price"
DBSETFILTER( &( "{|| sales->tip_ofer="+which+" .AND. sales->price_range=1 }"))
DBGOTOP()
DEFINE FONT oTipograf NAME "Arial" SIZE 0,-10
DEFINE DIALOG oRanges FROM 1,3 TO 19,81 TITLE letr FONT oTipograf
@ 1,.3 XBROWSE oBrw[1] ;
HEADER "Limit" ;
ARRAY aRanges ;
SIZE 60,120 of oRanges COLOR RGB(0,0,0),RGB(224,254,253) UPDATE
@ 1,8.75 XBROWSE oBrw[2] ;
FIELDS sales->code, IIF(sales->clasf>0,aVar[3][sales->clasf]," "), ;
IIF(sales->Type>0,aVar[6][sales->type]," "), ;
ALLTRIM(STR(sales->number,3,0)+' '+sales->street), sales->city ;
ALIAS "Sales" ;
HEADERS "Code","Clasification","Type","Address","Zip Code" ;
FIELDSIZES 80,80,45,140,120 ;
OF oRanges COLOR RGB(0,0,0),RGB(252,214,251) SIZE 230,120 UPDATE
oBrw[1]:nMarqueeStyle:= MARQSTYLE_HIGHLCELL
oBrw[1]:bChange := { || browse2(which,oRangss,oBrw) }
oBrw[2]:nClrText = { || IIF(client->rent_sale,CLR_HBLUE,CLR_BLACK) }
oBrw[2]:nClrForeFocus= { || IIF(client->rent_sale,CLR_HGREEN,CLR_WHITE) }
oBrw[2]:bLDblClick := {|| sales1(which,oRangos,oBrw,aVar) }
oBrw[1]:CreateFromCode()
oBrw[2]:CreateFromCode()
ACTIVATE DIALOG oRanges CENTERED ON INIT (bar_v(oRanges),browse2(which,oRanges,oBrw))
RELEASE FONT oTipograf
clean_areas()
RETURN
//----------------------------------------------------------------------------//
STATIC FUNCTION browse2(which,oRanges,oBrw)
clean_areas()
SELECT Sales
SET ORDER TO TAG "price"
DBSETFILTER( &( "{|| sales->tip_ofr="+which+" .AND. sales->price_range="+STR(oBrw[1]:nRowSel-1,1,0)+"}"))
DBGOTOP()
oBrw[2]:REFRESH(.t.)
* oBrw[1]:REFRESH(.t.) //do nor refresh the first browse or it will NOT respond to the keyboard and WILL LOOSE the position when doble clicking the second one and returning from another browse
oRanges:REFRESH()
oRanges:UPDATE()
Return (nil)
So the moral of all this entire story:
a) Do NOT worry about creating your "skip", "up", "down", "bottom", and "up" code; it is already created for you on the XBrowse code.
b) Only REFRESH the dependent xBrowse
c) Use the oBrw:nRowSel data to get the browse row pointer to work with.
Maybe FiveWin should do an entire working example to include on a future version. It will help hours of researching with a simple solution to a common problem: two dependent browse windows
Emiliano Llano