Xbrowse Filteraction from BarGetAction

Xbrowse Filteraction from BarGetAction

Postby Marc Venken » Tue Jan 11, 2022 10:23 pm

As far as I remember, it is up to the programmer to provide a function when we want something to happen when we use the BarGets from Xbrowse


The solution I now have is the folowing (several fields can be filled in the barget from the browse, but no dates or ranges of values...

Is someone having a better enhanced function to call for this or is this function ok (maybe some updates)

Code: Select all  Expand view  RUN


 :bBarGetAction := {|| ( oBrwSel:cAlias )->( SETFILTER( oBrwSel ) ) }

FUNCTION SETFILTER( oBrw ) // SETFILTER()?? INTERN COMMAND.

   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 + " )"
         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

 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests