To Nages : searching Xbrowse ( normal and tree)

To Nages : searching Xbrowse ( normal and tree)

Postby Silvio.Falconi » Wed Sep 11, 2024 11:53 am

how to simultaneously search for data (in a get and having a combobox to select the fields)
both in a normal xbrowse and in an xbrowse (the same one) made as a tree?

Do you want a minimal test?

I have already created the example in this topic : https://forums.fivetechsupport.com/viewtopic.php?f=3&t=44236&start=0&hilit=tree&sid=8d56f7c9c777efca30a1f0d4316a2ffe

normal xbrowse search works fine, when xbrowse turns into a tree the search doesn't work how to fix?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages : searching Xbrowse ( normal and tree)

Postby Silvio.Falconi » Fri Sep 13, 2024 7:27 am

I made a small modification to seek a data on tree, but now for a sample if I insert "Frank" it go to the first record called "frank"


see the function uSeekTree( oBrw, cSeek, oDbf ) , I not Know if it made ok

Image


Notice
instead if we search for the name "frank" from the normal browse and then switch to tree browse , the procedure displays only the names "Frank" which should also be displayed when searching in tree


tha sample with search function modifications

Code: Select all  Expand view

#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "report.ch"

REQUEST DBFCDX
 static lType1 := .f.


Function Main()
   local cDir:=".\data\"


 RDDSETDEFAULT( "
DBFCDX" )

   SET DATE ITALIAN
   SET CENTURY ON

   FwNumFormat( 'E', .t. )
   SetGetColorFocus()

         USE  &(cdir+"
Customer") NEW EXCLUSIVE ALIAS DB
         INDEX ON Upper(First) TAG FIRST FOR !Deleted()
         INDEX ON Upper(Last) TAG LAST FOR !Deleted()
         INDEX ON Upper(City) TAG CITY FOR !Deleted()
         INDEX ON Upper(State) TAG STATE FOR !Deleted()
         INDEX ON Upper(State)+Upper(First) TAG STATEFIRST FOR !Deleted()
         CLOSE DB


         Customer()

return nil


function Customer()
   local oDlg, oBrw, oFont,oBold
   local cSeek:=Space(100)
   local oSay:=array(2)
   local oGet
   local nWd  := GetSysMetrics(0) * .58
   local nHt  := (GetSysMetrics(1) / 2 ) -20
   local  aCols    := { ;
                   { "
FIRST",   "First"   ,,   120, },;
                   { "
LAST",    "Last"    ,,   120, },;
                   { "
STREET",  "Address" ,,   150, },;
                   { "
CITY",    "City"    ,,   100, },;
                   { "
STATE",   "State"   ,,    80, } }

 

   oDbf:=TCustomer():New()
   oDbf:SetOrder(1)
   oDbf:Gotop()



   DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
   DEFINE FONT oBold NAME 'Tahoma' SIZE 0, -14  BOLD
   DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL ;
   TITLE "
Demo Customer xbrowsetree" COLOR CLR_BLACK, nRGB( 245,245,235)

 @ 12,15 say oSay[1] Prompt "
Search " SIZE 46,24 PIXEL OF oDlg FONT oBold TRANSPARENT
 @ 10, 75 GET oGet VAR cSeek SIZE 200,21 PIXEL OF oDlg PICTURE "
@!"
 @ 12,290 say oSay[2] Prompt "
in" SIZE 20,24 PIXEL OF oDlg FONT oBold    TRANSPARENT

   @ 60,20 XBROWSE oBrw OF oDlg SIZE -10,-40 PIXEL ;
   DATASOURCE oDbf COLUMNS aCols ;
          AUTOSORT FONT oFont;
          NOBORDER CELL LINES


   WITH OBJECT oBrw
            :SetMultiSelectCol()
            :nRowHeight          := 25
            :l2007               := .F.
            :l2015               := .T.
            :lRecordSelector     := .F.
            :nColDividerStyle    := LINESTYLE_LIGHTGRAY
            :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
            :nStretchCol         := STRETCHCOL_WIDEST
            :nMarqueeStyle        := MARQSTYLE_HIGHLROW

             :lDrawBorder := .t.
             :nClrBorder := Rgb(195,195,185)
             :bClrStd := { || { CLR_BLACK, If( oBrw:KeyNo % 2 == 0, CLR_WHITE,CLR_HGRAY ) } }
             :lIncrFilter      := .t.
             :bOnSort          := { |b,oCol| oBrw:Seek( "
" ), ;
                                   oBrw:cFilterFld := oCol:cExpr, ;
                                   oBrw:SetFocus() }
             :oSeek := oGet

             :CreateFromCode()
          END

             *  xbrowser   oBrw:oSortCbx:aItems
       * aadd(oBrw:oSortCbx:aItems ,{ "
Starting With", "Containing" } )

    @ 10, 330 COMBOBOX oBrw:oSortCbx VAR oBrw:cSortOrder;
        SIZE 150,400 PIXEL OF oDlg HEIGHTGET 18 STYLE CBS_DROPDOWN

    //----------------------------------//
     @ 10, 500  BTNBMP oGroup Prompt "
Group on" ;
                FLAT  SIZE 80, 24  OF oDlg   PIXEL ;
                 RIGHT NOROUND;
                  ACTION ::ShowPopUp( { |oBtn| BtnPop( oBrw,oDbf,oGet) } )
    //----------------------------------//

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont, oBold
   RETURN NIL

//------------------------------------------------------------------------------//
Function BtnPop(oBrw,oDbf,oGet)
local oItem1,oItem2
MENU oMenu POPUP
           MENUITEM oItem1 PROMPT "
On State" ;
                 ACTION (lType1 := !lType1,;
                       ( Iif( lType1,Maketree(oBrw,oDbf,oGet),;
                                     MakeBrowse(oBrw,oDbf,oGet)  )))

             oItem1:SetCheck(lType1)

ENDMENU
RETURN oMenu
//---------------------------------------------------------------//
 Function  Maketree(oBrw,oDbf,oGet)
    local cSeek:=Space(100)
    local  aCols    := { ;
                   { "
STATE",   "State"   ,,    80, },;
                   { "
FIRST",   "First"   ,,   120, },;
                   { "
LAST",    "Last"    ,,   120, },;
                   { "
STREET",  "Address" ,,   150, },;
                   { "
CITY",    "City"    ,,   100, }  }

   /* local  aCols    := { ;
                   { "
FIRST",   "First"   ,,   120, },;
                   { "
LAST",    "Last"    ,,   120, },;
                   { "
STREET",  "Address" ,,   150, },;
                   { "
CITY",    "City"    ,,   100, },;
                   { "
STATE",   "State"   ,,    80, } }

     */

    oDbf:SetOrder("
State")   //state
    oDbf:Gotop()

      oBrw:ResetData( oDbf,aCols )


    WITH OBJECT oBrw
      :nStretchCol := 1

      :SetTree()
      :oTree:OpenAll()

      :lDisplayZeros := .f.
      :lIncrFilter      := .t.
              :bOnSort          := { |b,oCol| oBrw:Seek( "
" ), ;
                                   oBrw:cFilterFld := oCol:cExpr, ;
                                   oBrw:SetFocus() }
              :oSeek := oGet


           :bSeek := { |c| uSeekTree( oBrw, Upper(c),oDbf ) }


      :bClrStd := { || { CLR_BLACK, If( oBrw:oTreeItem:oTree == nil, CLR_WHITE, CLR_YELLOW ) } }
      :CreateFromCode()
   END
return nil
//----------------------------------------------------------------------//
 Function MakeBrowse(oBrw,oDbf,oGet)
     local  aCols    := { ;
                   { "
FIRST",   "First"   ,,   120, },;
                   { "
LAST",    "Last"    ,,   120, },;
                   { "
STREET",  "Address" ,,   150, },;
                   { "
CITY",    "City"    ,,   100, },;
                   { "
STATE",   "State"   ,,    80, } }

     oDbf:Setorder(1)
     oDbf:Gotop()

     oBrw:ResetData( oDbf,aCols )

       WITH OBJECT oBrw
            :SetMultiSelectCol()
            :nRowHeight          := 25
            :l2007               := .F.
            :l2015               := .T.
            :lRecordSelector     := .F.
            :nColDividerStyle    := LINESTYLE_LIGHTGRAY
            :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
            :nStretchCol         := STRETCHCOL_WIDEST
            :nMarqueeStyle        := MARQSTYLE_HIGHLROW

             :lDrawBorder := .t.
             :nClrBorder := Rgb(195,195,185)
             :bClrStd := { || { CLR_BLACK, If( oBrw:KeyNo % 2 == 0, CLR_WHITE,CLR_HGRAY ) } }
             :lIncrFilter      := .t.
             :bOnSort          := { |b,oCol| oBrw:Seek( "
" ), ;
                                   oBrw:cFilterFld := oCol:cExpr, ;
                                   oBrw:SetFocus() }
             :oSeek := oGet
             :CreateFromCode()
          END
   RETURN NIL
//-------------------------------------------------------------------------//

 CLASS TXData from TDatabase
      DATA cPath   init "
.\Data\"
ENDCLASS

CLASS TCustomer from TXData
   METHOD New()
ENDCLASS

METHOD New( lShared ) CLASS TCustomer
   Default lShared := .t.
   ::super:New(,::cPath+"
Customer" ,"DBFCDX", lShared)
   if ::use()
      ::setOrder(1)
      ::gotop()
   endif
RETURN Self
//-------------------------------------------------------------------------//





STATIC FUNCTION uSeekTree( oBrw, cSeek,oDbf )

 LOCAL oTree  := oBrw:oTree
 LOCAL oFound, oItem := oTree:oFirst
 LOCAL lFound := .F.
 local nOrder :=oDbf:SetOrder()


    oDbf:SetOrder(5)   //state +First
    oDbf:Gotop()

 oBrw:cSeek := cSeek

 DO WHILE oItem <> NIL

    IF oBrw:cSeek $ Upper(SubStr(oItem:cPrompt,1,Len(oBrw:cSeek)))
       oFound := oItem
       EXIT
    ENDIF

    oItem := oItem:GetNext()

 ENDDO

 IF oFound <> nil
    oBrw:oTreeItem := oFound
    oBrw:Refresh()
    lFound := .t.
 ENDIF

RETURN lFoun
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages : searching Xbrowse ( normal and tree)

Postby Silvio.Falconi » Tue Oct 01, 2024 6:55 am

Mr. Rao do you have found a solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7061
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests