To Nages : Search on Xbrowse tree

To Nages : Search on Xbrowse tree

Postby Silvio.Falconi » Thu Feb 15, 2024 12:04 pm

I want to display the normal xbrowse first and then recall the tree through a combobox
and have in both cases the possibility of searching for a customer through the get control and the oBrw:oSortCbx combobox
and also to add on oBrw:oSortCbx { "Starting With", "Containing" }

I used customer.dbf and set the index only on this fields FIRST ,LAST, CITY, STATE
But for my application I use another dbf with other index and I wish show the tree on different fields
in my application I have an archive of warehouse items (products) where I would like to display a tree view for different fields (categories and brand)

Xbrowse normal
Image

xbrowse tree
Image

the normal and tree view works ok only I can only search in the normal view and not in the tree view
to select normal and tree view I inserted a BTNBMP control with a popup menu

this is the sample test

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()
         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

      :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
//-------------------------------------------------------------------------//




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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages : Search on Xbrowse tree

Postby Silvio.Falconi » Wed Mar 27, 2024 1:20 pm

please any 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: 6768
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 72 guests