Incremental search in filtered array

Incremental search in filtered array

Postby acuellar » Thu Jul 23, 2020 7:51 am

With this example
Code: Select all  Expand view  RUN


#include "fivewin.ch"

Function Main()

   local oDlg, oBrw, oFont
   local aData

   USE CUSTOMER
   aData := FW_DbfToArray( "FIRST,LAST,STATE" )
    CLOSE CUSTOMER

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 700,500 PIXEL TRUEPIXEL FONT oFont

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS HEADERS "First", "Last", "State" ;
      CELL LINES NOBORDER FOOTERS AUTOSORT

   WITH OBJECT oBrw
      :lIncrFilter:= .t.
      :lSeekWild  := .t.
      :aCols[ 1 ]:bFooter  := { || "Records : " + Str( oBrw:nLen ) }
      :CreateFromCode()
     
   END
   @ 20,450 SAY oBrw:oSeek VAR oBrw:cSeek SIZE 150,20 PIXEL OF oDlg COLOR { 0,16777215 }
   @ 10, 20 BTNBMP PROMPT "Set Filter" SIZE 200,40 PIXEL OF oDlg FLAT ;
      ACTION ( xSetFilter( oBrw ), oBrw:SetFocus() )

   @ 10,240 BTNBMP PROMPT "Clear Filter" SIZE 200,40 PIXEL OF oDlg FLAT ;
      ACTION ( xClearFilter( oBrw ), oBrw:SetFocus() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

Return nil

Function xSetFilter( oBrw )
   local cFilter  := ""
   local oCol, c
 
   cFilter:= "'NY' $ Upper( cValToChar( aRow[3] ) )"
   cFilter  := "{ |c,aRow,oBrw| " + cFilter + " }"
   oBrw:bFilterExp  := &( cFilter )
   oBrw:ArrayIncrFilter( "dummy" )
   oBrw:Refresh()
   oBrw:SetFocus()
Return .t.

Function xClearFilter( oBrw )
   If oBrw:nLen < Len( oBrw:aArrayData )
      oBrw:bKeyCount    := { || Len( oBrw:aArrayData ) }
      oBrw:Refresh()
   Endif
   oBrw:SetFocus()
   If oBrw:nLen >= 2
      ASort( oBrw:aArrayData,,, { |x, y| if( x[1]==y[1], x[2]<y[2], x[1]<y[1] ) })
   EndIF
return .t.
 

Giving Set Filter filters it by State = "NY". I need to do incremental search on the filtered.

Thanks for the help

Regards
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1644
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Incremental search in filtered array

Postby nageswaragunupudi » Fri Jul 24, 2020 11:36 pm

Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 70 guests