I have a DCBrowse of an SQLDataSet (SQLExpress and Oracle 11g). Everything works just fine with the browse, however I wanted to take advantage of the :BrowseFilter property of SQLDataSets to allow the user to filter the data based on the value of one of the fields. I had previously done this when it was foxpro tables using dc_setscope. The list is essentially a browse of different types of entries in an event log and the filter functionality allows the user to say "Let me see only events related to X"
When I try to use the :BrowseFilter property however, the DCBrowse itself goes wonky, always forcing the browse to the bottom row and not allowing the user to scroll up. I can grab the scrollbar and force it up for a second (at which point I can see that the filter did work), but even then, the browse will quickly reposition itself back to the bottom row after a second. If I remove the :BrowseFilter property (set it back to NIL) then everything behaves correctly again.
Has anyone run into anything similar?
Due to the nature of the environment and the work I cannot give you fully compilable / runable code but here are some relevent code snippets for what its worth.
Code: Select all
Local bEventRefresh := {|| LoadEventLog(aLocals),;
DC_GETREFRESH( GetList, nil,DCGETREFRESH_ID_INCLUDE,{"EVT"}),DC_GetOrigSet(GetList) }
// making the cursor
If !MakeCursor(@oEVENTLOG,SELECT_EVENTLOG+" WHERE CASE_ID=? ORDER BY EVENTDATE DESC", {|| { oCASES:FieldGet("CASE_ID")} } )
ErrorMsg("Unable to Open EventLog Table")
Break
Endif
// throw up the browse
@ 0.2,0.2 DCBROWSE oBrowEvent DATA oEVENTLOG ;
SIZE 60,nBHeight-5.2 PARENT oBoxEvent CURSORMODE XBPBRW_CURSOR_ROW ;
PRESENTATION aBrowPres EVAL bScrollBars ;
ITEMMARKED bEventRefresh ; //SCOPE ; //DESCENDING;
ITEMSELECTED {|| IIF(Eval(bEvtEditWhen),Eval(bEvtEditAction),nil) }
//-------------------------------------------------------------------------------
Function MakeCursor(oCurs,cSelect,aParams,nRows)
//-------------------------------------------------------------------------------
Local lOk:=.t.
default aParams to {}
default nRows to 0
Begin Sequence
oCurs:=CreateSQLDataSet(_goCONN,cSelect,aParams,@nRows)
lOk:=ValType(oCurs)=="O"
EndSequence
Return lOk
//-----------------------------------------------------------------------------
FUNCTION CreateSQLDataSet( oConnection, cStatement,aParams, nRows )
//-----------------------------------------------------------------------------
Local oCursor, nSuccess := SQL_XPP_ERROR
Local oWin:=SetAppWindow()
dc_pointerwait(oWin)
default aParams to {}
default nRows to 0
default oConnection to _goCONN
Begin Sequence
If ValType(oConnection)<>"O"
GetConnected()
oConnection:=_goCONN
ElseIf !oConnection:IsConnected
GetConnected()
oConnection:=_goCONN
Endif
oConnection:displayErrors := .t.
oCursor := SQLDataSet():new(cStatement, oConnection, aParams ,,,,,.t.,.t.)
nSuccess := oCursor:execute()
If nSuccess<>SQL_XPP_ERROR
nRows := nSuccess
Endif
oConnection:displayErrors := .f.
EndSequence
dc_pointerArrow(oWin)
RETURN oCursor
//-------------------------------------------------------------------------------
Function EventFilter(aLocals)
//-------------------------------------------------------------------------------
Local GetList[0], GetOptions[0]
Local cStart:="000000SH00"
Local cEnd:="999999SH99"
Local oGroup
Local lOk:=.f.
Local nPick:=1
@ 0,0 DCGROUP oGroup SIZE 40,9
@ 1,2 DCSAY "Filter Event Log for 'Relates To' Type" SAYSIZE 0 SAYLEFT
@ 2,2 DCRADIO nPick PROMPT "All Types" VALUE 1
@ 3,2 DCRADIO nPick PROMPT "Cases" VALUE 2
@ 4,2 DCRADIO nPick PROMPT "Incidents" VALUE 3
@ 5,2 DCRADIO nPick PROMPT "Respondents" VALUE 4
@ 6,2 DCRADIO nPick PROMPT "Complainants" VALUE 5
@ 7,2 DCRADIO nPick PROMPT "Employers" VALUE 6
DCGETOPTIONS NOMIN NOMAX AUTORESIZE TABSTOP ENTEREXIT
DCREAD GUI FIT TITLE "Filter Event Log" ;
OPTIONS GETOPTIONS ;
ADDBUTTONS ;
TO lOk ;
MODAL
If lOk
Do Case
Case nPick=1
oEVENTLOG:BrowseFilter := NIL
cEVT_FILTER:="All Event Types"
Case nPick=2
oEVENTLOG:BrowseFilter := {|aRow,nRow,oData| oData:FieldGet("SH_ID")==_STK_CASE}
cEVT_FILTER:="Cases"
Case nPick=3
oEVENTLOG:BrowseFilter := {|aRow,nRow,oData| oData:FieldGet("SH_ID")==_STK_INCIDENT}
cEVT_FILTER:="Incidents"
Case nPick=4
oEVENTLOG:BrowseFilter := {|aRow,nRow,oData| oData:FieldGet("SH_ID")==_STK_RESPONDENT}
cEVT_FILTER:="Respondents"
Case nPick=5
oEVENTLOG:BrowseFilter := {|aRow,nRow,oData| oData:FieldGet("SH_ID")==_STK_COMPLAINANT}
cEVT_FILTER:="Complainants"
Case nPick=6
oEVENTLOG:BrowseFilter := {|aRow,nRow,oData| oData:FieldGet("SH_ID")==_STK_EMPLOYER}
cEVT_FILTER:="Employers"
EndCase
oEVENTLOG:GoTop()
Endif
Return nil
Thanks,
Stu