We have the option to run a function that we make to process the data.
I started to use it for every Xbrowse i have in use and it is working pretty well. The point is that I use a filter to collect the data and not a scooped filter/index
So maybe my function is not that optimised for the use I have. I do use several fields for a filter to work and these fields not always have indexes. Maybe the should ?
Should I consider having a extended call to the function marc_setfilter(oBrwsel,"CustName") and insite the function make a selection for using scoped or filtered data
do case
case cData = "CustName"
... set index name
... scope the data for quick access
case cData = "CustStreet"
set index street
scope the data
otherwise // more fields have been filled in, so filtering will be a better option
do the filter stuff
endcase
here is my current filtercode :
- Code: Select all Expand view RUN
// From insite the Xbrowse setup
oBrwSel:lGetBar := .T. // Button to activate
if len(aBarget)>0
FOR EACH cCol in aBarget
WITH OBJECT oBrwSel:oCol( cCol )
:uBarGetVal := uValBlank( :Value )
:cBarGetPic := :cEditPicture
:bClrEdit := {|| { CLR_BLACK, MY_LIGHTYELLOW } }
:lBarGetOnKey := .T. // after having setfocus the oBrowse object, the end user can insert the characters directly into the get
:bBarGetAction := {|| ( oBrwSel:cAlias )->( MARC_SETFILTER( oBrwSel ) ) } // this for show the bitmap on the get and associated a action
END
NEXT
endif
//
FUNCTION MARC_SETFILTER( oBrw )
LOCAL cFilter := ""
LOCAL n, oCol, uVal, cType
FOR n := 1 TO Len( oBrw:aCols )
oCol := oBrw:aCols[ n ]
IF ! Empty( uVal := oCol:uBarGetVal )
IF !Empty( cFilter )
cFilter += " .AND. "
ENDIF
cType := ValType( uVal )
DO CASE
CASE cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + oCol:CExpr + " )"
// for data starting with text
//cFilter += "UPPER( " + oCol:cExpr + " ) = '" + uVal + "'"
// for data EXACT
//cFilter += "UPPER( ALLTRIM( " + oCol:cExpr + " ) ) == '" + uVal + "'"
CASE cType == 'D'
cFilter += oCol:cExpr + " = " + ( uVal )
OTHERWISE
cFilter += oCol:cExpr + " == " + cValToChar( uVal )
ENDCASE
ENDIF
NEXT
IF Empty( cFilter )
IF ! Empty( dbFilter() )
dbClearFilter()
oBrw:Refresh()
ENDIF
ELSE
IF !( dbFilter() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrw:Refresh()
ENDIF
ENDIF
oBrw:SetFocus()
RETURN NIL