FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour bug xBrowse in ::cFilterFld
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
bug xBrowse in ::cFilterFld
Posted: Sun Aug 10, 2014 02:09 PM
Hello,

I have a combobox with the fields explained with a different Array.

When I change the ítem on the combobox, oBrw:cFilterFld is not updated. Always takes FIRST, but I need to change it.

This is my code:

Code (fw): Select all Collapse
#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'



REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oBrw, oFont, nWild := 2
   local cList, aFlds, aHdrs
   local nChoice := 0, uDataSource

   local aMyFields := { "First Name", "Last Name", "Address customer" }
   local oCbx1, myvar


   SET DATE ITALIAN
   SET CENTURY ON
   RDDSETDEFAULT( "DBFCDX" )

   cList := "First,Last,Street,State,HireDate"

   //nChoice     := ALERT( "Choose Data Souce", { "DBF", "ADO", "ARRAY" } )
   uDataSource := OpenData( nChoice, cList )




   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 750,300 PIXEL FONT oFont ;
      TITLE "XBrowse Incremental Filters"

   aFlds := aHdrs := HB_ATokens( cList, ',' )
   if nChoice == 3
      aFlds := Array( Len( aFlds ) )
      AEval( aFlds, { |u,i| aFlds[ i ] := i } )
   endif

   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      COLUMNS aFlds HEADERS aHdrs ;
      DATASOURCE uDataSource AUTOSORT CELL LINES NOBORDER ;
      FASTEDIT

   WITH OBJECT oBrw
      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 2 )
      :cFilterFld    := "FIRST"
      :nStretchCol   := STRETCHCOL_WIDEST

      :nColDividerStyle    := LINESTYLE_BLACK
      :lColDividerComplete := .T.
      :nHeaderLines        := 1.5
      :lRecordSelector     := .F.
      :lAllowColHiding     := .F.

      :nMarqueeStyle := 7

      :bLButtonUp := { |r,c,f,o| If( o:SelectedCol():lEditable, o:SelectedCol():Edit(), nil )  }

 //:lEnterKey2Edit := .f.
 //:lF2KeyToEdit := .t.

   END

   AEval( oBrw:aCols, { |o| o:nEditType := EDIT_GET } )


/*
   @ 10, 10 COMBOBOX oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE ( oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 50,400 PIXEL OF oDlg
*/

   MyVar := aMyFields[1]

   @ 10, 10 COMBOBOX oCbx1 ;
      VAR MyVar  ;
      ITEMS aMyFields ;
      ON CHANGE ( oBrw:Seek( "" ), oBrw:cFilterFld( aFlds[oCbx1:nAt] ), msginfo("It does not reflect the change: "+oBrw:cFilterFld, "oBrw:cFilterFld is "), oBrw:SetFocus() ) ;
      SIZE 50,400 PIXEL OF oDlg





   @ 10, 70 COMBOBOX nWild ITEMS { "Starting With", "Containing" } ;
      ON CHANGE ( oBrw:lSeekWild := ( nWild == 2 ), ;
                  oBrw:Seek( If( oBrw:lSeekWild, oBrw:cSeek, "" ) ), ;
                  oBrw:SetFocus() ) ;
      SIZE 70,400 PIXEL OF oDlg

   @ 11,160 SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE 200,10 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED ON INIT ( oBrw:SetFocus(), .f. )

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function OpenData( nSource, cList )

   local oCn, uSource

      USE c:\fwh\samples\CUSTOMER SHARED NEW ALIAS CUST
      SET ORDER TO TAG FIRST
      GO TOP
      if nSource == 3
         uSource  := CUST->( FW_DbfToArray( cList ) )
         CLOSE CUST
      else
         uSource  := "CUST"
      endif


return uSource

//----------------------------------------------------------------------------//

Continue the discussion