In my xbrowser's i use the folowing syntax for my BargetAction, that i use alot.
- Code: Select all Expand view RUN
// xbrowse setup ...
:bBarGetAction := {|| ( oBrwSel:cAlias )->( MARC_SETFILTER( oBrwSel ) ) }
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 + " )"
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
1. I wonder if this code is still optimised for the current version of FW. The code is somewhere from the forum, but sure a longer time ago. Changes needed ?
2. If I put data in a field like : Ref123 this code will show also Ref123 and Ref12345 and dataRef123 . I would like a checkbox to set exact or so for only Ref123
3. Does this function work any better (faster) if I set a index of any kind. Now a index is active, but not related to a search column