XBrowse: Using Get for incremental Seek/Filters

XBrowse: Using Get for incremental Seek/Filters

Postby nageswaragunupudi » Wed Dec 09, 2020 12:20 am

We use a SAY control to display text entered by the user for incremental seek/filter like this:
Code: Select all  Expand view

@ r, c SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE w,h PIXEL OF oDlg
 


There are situations when the programmer prefers to use a GET control for input of search expression. But in the present implementation, this is not supported by xbrowse.

In the version under release, this is made very simple.

Sample:
Code: Select all  Expand view

#include "fivewin.ch"

REQUEST DBFCDX

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

function Main()

   local oDlg, oGet, oBrw
   local cSeek := Space( 100 )

   SetGetColorFocus()

   FERASE( "CUSTOMER.CDX" )
   USE CUSTOMER NEW EXCLUSIVE VIA "DBFCDX"
   FW_CdxCreate()
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL

   @ 20,20 GET oGet VAR cSeek SIZE 460,20 PIXEL OF oDlg

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" ;
      AUTOCOLS AUTOSORT CELL LINES NOBORDER

   WITH OBJECT oBrw
      :lIncrFilter   := .t.
      :oSeek         := oGet // Required before :CreateFromCode()
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED

return nil
 


When Get has the focus, the text entered by the user is used for the incremental search/filter. If the search/filter fails, the user's keystroke is discarded.

When the browse has focus, the user can continue entering further characters and the Get is updated correctly.

The user can alternate between Get and Browse retaining the continuity.

Notes:
1) Create the Get using a different variable (eg: oGet) but not oBrw:oSeek and use a different variable with adequate width but not oBrw:cSeek as in the above example.
2) Assign oBrw:oSeek := oGet, before calling oBrw:CreateFromCode().
3) Use character variable irrespective of the data type of the search field.
4) Do not define bChange or bKeyDown or bKeyChar for the Get. XBrowse automatically creates necessary codeblocks. Keep the application code as simple as shown in the above sample.

Image
Regards

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Wed Dec 09, 2020 12:19 pm

THANKS MR RAO
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Sat Dec 12, 2020 9:28 am

Dear Mr Rao
a question

I tried to make a my sample test

Image

I add also a combobox to select column fields as you can see on Picture

Records Selected
I add a first column to check, I saw if I select one customer then the print procedure print all customer
If I select two custoer then the print procedure print two customer ( selected)

I made
Code: Select all  Expand view
 WITH OBJECT oBrw:InsCol(1)
                :nwidth:= 30
                :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
                :SetCheck( nil, .t.)
                :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
                :bFooter       := { || ltrim(Str( Len(oBrw:aSelected))) }
                :bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }

             End

           :bLClicked := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                           If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                             AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                             ADel( oBrw:aSelected, f, .t. ) ), Nil ), ;
                             oBrw:RefreshCurrent() }

 



I add also these lines

:bChange := { |o| o:RefreshFooters() }
:bKeyChar := { |k| If( k == VK_SPACE, ( oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent(), 0 ), nil ) }
:bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }
:bClrStd := { || { CLR_BLACK, If( oBrw:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }

but :bKeyChar is not executed , I press space and it not select the record

the cause may depend on the research procedure?
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Mon Dec 28, 2020 11:54 am

Dear Nages,
your sample run perfectly
But I need to change the text of Header
and I add a combobox with the text of columns

when I go to search it not found the name of first column "Dip"

on change of combobox I tried to save on oBrw:cFilterFld the value of column selected

@ 20, 280 COMBOBOX oCbx var oBrw:cFilterFld ;
ITEMS aHdrs ;
ON CHANGE ( nField:=::nat,;
oBrw:cFilterFld := aColumns[nField],;
msginfo( oBrw:cFilterFld ),;
oBrw:Seek( "" ), oBrw:SetFocus() ) ;
SIZE 150,400 PIXEL OF oDlg


ACTIVATE DIALOG oDlg CENTERED ;
on init (nField:=1,oBrw:cFilterFld := aColumns[nField],oCbx:select(nField))

but it make me error

Error description: Error BASE/1003 Variable does not exist: DIP

Stack Calls
===========
Called from: xbrowse.prg => TXBROWSE:RDDINCRFILTER( 7450 )
Called from: xbrowse.prg => TXBROWSE:RDDINCRSEEK( 7375 )
Called from: xbrowse.prg => (b)TXBROWSE_SETRDD( 5643 )
Called from: xbrowse.prg => TXBROWSE:SEEK( 8992 )



How I can resolve it ?
my test
Code: Select all  Expand view
//----------
#include "fivewin.ch"

REQUEST DBFCDX

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

function Main()

   local oDlg, oGet, oBrw
   local cSeek := Space( 100 )
   local cHeaders := "Dip,Last,Street,State,HireDate"
   local aColumns := {"FIRST","LAST","STREET","STATE","HIREDATE"}
   local oFont,oBold
   local oCbx,nField

   SetGetColorFocus()
   aHdrs := HB_ATokens( cHeaders, ',' )
   nField:= 1

   USE CUSTOMER NEW SHARED VIA "DBFCDX"
   *INDEX ON FIRST TAG FIRST TO CUSTOMER
   FW_CdxCreate()
   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
   DEFINE FONT oBold  NAME 'Tahoma' SIZE 0, -14 BOLD

   DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL

   @ 21 ,3 SAY oSay1 Prompt "Search " ;
                FONT oBold SIZE 120,20 PIXEL OF oDlg  TRANSPARENT


   @ 20,60 GET oGet VAR cSeek SIZE 200,20 PIXEL OF oDlg

   oGet:bChange := <| nKey, nFlags, Self |
      if ::oGet:Buffer != nil .and. !oBrw:Seek( Trim( ::oGet:buffer ) )
         ::cText := PadR( oBrw:cSeek, Len( ::VarGet() ) )
         ::SetPos( Len( oBrw:cSeek ) + 1 )
      endif
      return nil
      >


   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUSTOMER" ;
      AUTOCOLS AUTOSORT CELL LINES NOBORDER

   WITH OBJECT oBrw
      :lIncrFilter := .t.
      :cFilterFld    := aColumns[nField]
      :oSeek   := oGet
      :CreateFromCode()
   END


    @ 20 ,  265 Say oSay2 Prompt  "in"  ;
               FONT oBold SIZE  55,   20 PIXEL   OF oDlg

    @ 20, 280 COMBOBOX oCbx var oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE (  nField:=::nat,;
                   oBrw:cFilterFld := aColumns[nField],;
                    msginfo( oBrw:cFilterFld ),;
                    oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 150,400 PIXEL OF oDlg



    ACTIVATE DIALOG oDlg CENTERED ;
    on init (nField:=1,oBrw:cFilterFld := aColumns[nField],oCbx:select(nField))

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Antonio Linares » Mon Dec 28, 2020 12:19 pm

Silvio,

This line should be like this:

local cHeaders := "Fist,Last,Street,State,HireDate"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42059
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Mon Dec 28, 2020 4:43 pm

Antonio Linares wrote:Silvio,

This line should be like this:

local cHeaders := "Fist,Last,Street,State,HireDate"


Sorry Antonio,
I made this morning a mistake
I copied a bad test , the test is this ...

Code: Select all  Expand view

#include "fivewin.ch"
#include "constant.ch"
#include "ttitle.ch"

        REQUEST HB_Lang_IT
        REQUEST HB_CODEPAGE_ITWIN


        REQUEST DBFCDX
        REQUEST DBFFPT
        EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO


      FUNCTION Main()
           local cDbf     := "Cust"
           local aBrowse


            HB_LangSelect("IT")
            HB_SetCodePage("ITWIN")

            SET _3DLOOK ON
            SET CENTURY ON
            SET DATE ITALIAN

            RDDSetDefault( 'DBFCDX' )

           cIniFile    := cFilePath( GetModuleFileName( GetInstance() ) ) + "tabledb.ini"


            USE CUSTOMER  ALIAS CUST
           INDEX ON FIRST  TAG FIRST    TO TMFIRST  MEMORY
           INDEX ON LAST   TAG LAST     TO TMPLAST  MEMORY
           INDEX ON CITY   TAG CITY     TO TMPCITY  MEMORY
           INDEX ON STATE  TAG STATE    TO TMPSTATE MEMORY


            cust->(dbsetorder(1))
            cust->(dbgotop())




             // { field, header, picture, size, justify, sortorder }

            aBrowse   := { { "CUST->FIRST",  "Nome",,               120, },;
                           { "CUST->LAST",   "Cognome",,                120, },;
                           { "CUST->STREET", "Indirizzo",,              180, },;
                           { "CUST->CITY",   "Città",,                150, },;
                           { "CUST->STATE",  "Stato",,               50, }}


                bedit:= { || MsgInfo( "modify" ) }

           TableDb(aBrowse,cDbf,"Customers table","Cust",bedit)

           RETURN NIL
//------------------------------------------------------------------//
 Function TableDb(aBrowse,cDbf,cTitle,cPrefix,bedit)

           local oTabella
           local oBrw,oSay1,oSay2
           local oFont,oFontSmall,oBold
           local  oCursorBtn :=TCursor():New(,'HAND')

           local  nBottom   := 28
           local  nRight    := 99.9
           local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
           local  nHeight   := nBottom * DLG_CHARPIX_H

           local  aBtnBrow  := array(4)
           local  aBtnNav   := array(4)
           local aHdrs := {}  //Headers
           local aColumns := {}

           local cSeek := Space( 100 )
           local oGet,oGet2
           local nField := 1
           // da personalizzare

           local cImage:= ".\bitmaps\clienti.bmp"
           local cTitle1:= "Customers"
           local cTitle2:= "Insert the customer to search"


           AAdd( aHdrs, "" )
           AAdd( aColumns, "" )

               for n= 1 to Len(aBrowse)
                  AAdd( aHdrs, aBrowse[n][2] )
                  AAdd( aColumns, aBrowse[n][1] )
               next

             DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
             DEFINE FONT oFontSmall NAME 'Tahoma' SIZE 0, -14
             DEFINE FONT oBold  NAME 'Tahoma' SIZE 0, -14 BOLD



          DEFINE DIALOG oTabella  TITLE cTitle   ;
              SIZE nWidth, nHeight  FONT  oFont ;
              PIXEL TRUEPIXEL RESIZABLE COLOR CLR_BLACK,  nRgb( 245,244,234)



          @ 0,0 TITLE  oTitle OF oTabella size oTabella:nwidth, 60 BORDER SHADOW NOSHADOW   ;
                               GRADIENT { { 1, CLR_WHITE, CLR_WHITE } }
          @ 10, 12 TITLETEXT OF oTitle TEXT cTitle1 FONT oBold COLOR CLR_GRAY
          @ 28, 12 TITLETEXT OF oTitle TEXT cTitle2 FONT oFont COLOR CLR_HGRAY
          @ 10, 12  TITLEIMG oImg  OF oTitle  BITMAP cImage  SIZE 50,50 TRANSPARENT


           @ 66,3 SAY oSay1 Prompt "Search " ;
                    FONT oBold SIZE 120,20 PIXEL OF oTabella  TRANSPARENT
          @ 42,  181 Say oSay2 Prompt  "in"  ;
                   FONT oBold SIZE  55,   20 PIXEL   OF oTabella  TRANSPARENT



         DEFINE BUTTONBAR oBar OF oTabella SIZE 70,70  BOTTOM NOBORDER  2010
               DEFINE BUTTON OF oBar PROMPT "New"    FILENAME ".\BITMAPS\NUOVO.PNG"        ACTION If( oBrw:bEdit == nil, oBrw:Edit( .t. ), oBrw:EditSource( .t. ) )
               DEFINE BUTTON OF oBar PROMPT "Modify" FILENAME ".\BITMAPS\PENCIL.PNG"   GROUP  ACTION If( oBrw:bEdit == nil, oBrw:Edit(), oBrw:EditSource() )
               DEFINE BUTTON OF oBar PROMPT "Delete" FILENAME ".\BITMAPS\CAN.PNG"   ACTION ( If( MsgNoYes( "Delete Record?" ), oBrw:Delete(), nil ), oBrw:SetFocus() )
               DEFINE BUTTON OF oBar PROMPT "Print"  FILENAME ".\BITMAPS\print.bmp"     ACTION  If( Empty( oBrw:bPrint ), oBrw:Report(), oBrw:Print() )
               DEFINE BUTTON OF oBar PROMPT "Exit"   FILENAME ".\BITMAPS\exit.bmp"      GROUP ACTION oTabella:End()


              oBar:bClrGrad := { | lPressed | If( ! lPressed,;
                               { { 1,  nRgb(233,229,206),nRgb(233,229,206) } },;
                               { {  1, nRgb( 245,244,234), nRgb( 245,244,234) } } ) }


               @ 40,  65 GET oGet VAR cSeek SIZE  250,  25 PIXEL OF oTabella

      oGet:bChange := <| nKey, nFlags, Self |
      if ::oGet:Buffer != nil .and. !oBrw:Seek( Trim( ::oGet:buffer ) )
         ::cText := PadR( oBrw:cSeek, Len( ::VarGet() ) )
         ::SetPos( Len( oBrw:cSeek ) + 1 )
      endif
      return nil
      >



              @ 100,5 XBROWSE oBrw  ;
                   SIZE 385,130 PIXEL;
                   OF oTabella ;
                   ALIAS cDbf COLUMNS aBrowse NOBORDER  FOOTERS



      WITH OBJECT oBrw

        WITH OBJECT oBrw:InsCol(1)
                :nwidth:= 30
                :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
                :SetCheck( nil, .t.)
                :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
                :bFooter       := { || ltrim(Str( Len(oBrw:aSelected))) }
                :bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }

             End

           :bLClicked := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                           If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                             AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                             ADel( oBrw:aSelected, f, .t. ) ), Nil ), ;
                             oBrw:RefreshCurrent() }


           :lIncrFilter := .t.
          :cFilterFld    := aColumns[nField]
           :oSeek   := oGet

           :l2007:=.f.
           :lColDividerComplete := .t.
           :lRecordSelector     := .t.
           :lHScroll            := .f.
           :nHeaderHeight       := 30
           :nRowHeight          := 30
           :nFooterHeight       := 30
           :nStretchCol         := -1
           :lDrawBorder := .t.
           :nRecSelColor     :=   nRgb( 245,244,234)
           :bClrHeader       := {|| { ,nRgb(233,229,206) } }
           :bClrFooter       := {|| { ,nRgb( 245,244,234) } }
           :nColDividerStyle := LINESTYLE_LIGHTGRAY
           :nRowDividerStyle := LINESTYLE_LIGHTGRAY


              :bChange  := { |o| o:RefreshFooters() }
              :bKeyChar   := { |k| If( k == VK_SPACE, ( oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent(), 0 ), nil ) }
              :bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }
              :bClrStd    := { || { CLR_BLACK, If( oBrw:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }



           :nRecSelColor     :=   nRgb( 245,244,234)
           :bClrHeader       := {|| { ,nRgb(233,229,206) } }
           :bClrFooter       := {|| { ,nRgb( 245,244,234) } }


      :CreateFromCode()
   END








       @ 20, 280 COMBOBOX oGet2 var oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE (  nField:=::nat,;
                   oBrw:cFilterFld := aColumns[nField],;
                    msginfo( oBrw:cFilterFld ),;
                    oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 150,400 PIXEL OF oTabella



         oTabella:bResized  := <||
                   local oRect       := oTabella:GetCliRect()
                   oTitle:nWidth     := oRect:nRight
                   oBrw:nWidth       := oRect:nRight-10
                   oBrw:nHeight      := oRect:nbottom-210
                   oImg:aImgs[2]     := oRect:nRight-60
                   oGet:nTop      := oTitle:nBottom+5
                   oGet:nLeft     := oRect:nLeft+90
                   oSay1:nTop        := oTitle:nBottom+7
                   oSay1:nLeft       := oRect:nLeft+10
                   oSay2:nTop        := oTitle:nBottom+7
                   oSay2:nLeft       := oRect:nLeft+360
                   oGet2:nTop      := oTitle:nBottom+5
                   oGet2:nLeft     := oRect:nLeft+380

                   return nil
                     >

                oTabella:aMinMaxInfo := { nil, nil, nil, nil, 650,350, nil, nil }

 ACTIVATE DIALOG oTabella CENTERED ;
     ON INIT  ( nField:=1,;
                oBrw:cFilterFld := aColumns[nField],;
                oGet2:select(nField),;
                oTabella:resize(),;
                ChangeButtons( oBar ),;
             EVAL( oTabella:bResized)  )
 RETURN NIL


   //-----------------------------------------------------------------//
function ChangeButtons( oBar )

   AEval( oBar:aControls, { | oCtrl | oCtrl:nTop += 4, oCtrl:nHeight -= 4 } )

return .T.
//-----------------------------------------------------------------//



 


I change the combo with this but not run
Code: Select all  Expand view


@ 20, 280 COMBOBOX oCbx var oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE (  nField:=::nat,;
                   oBrw:cFilterFld := aColumns[nField],;
                    msginfo( oBrw:cFilterFld ),;
                    oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 150,400 PIXEL OF oTabella

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Mon Dec 28, 2020 10:15 pm

nageswaragunupudi wrote:We use a SAY control to display text entered by the user for incremental seek/filter like this:
Code: Select all  Expand view

@ r, c SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE w,h PIXEL OF oDlg
 


There are situations when the programmer prefers to use a GET control for input of search expression. But in the present implementation, this is not supported by xbrowse.

In the version under release, this is made very simple.




Nages,
I wish use your sample + ComboBox -> not run ok not change the columns

How I can resolve ?


Code: Select all  Expand view


    #include "fivewin.ch"

    REQUEST DBFCDX

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

    function Main()

       local oDlg, oGet, oBrw
       local cSeek := Space( 100 )
       local oCbx
       local aColumns :={"ID","FIRST","LAST"}
       LOCAL nField:=  2
       SetGetColorFocus()

       FERASE( "CUSTOMER.CDX" )
       USE CUSTOMER NEW EXCLUSIVE VIA "DBFCDX"
       FW_CdxCreate()
       SET ORDER TO TAG FIRST
       GO TOP

       DEFINE DIALOG oDlg SIZE 500,500 PIXEL TRUEPIXEL

       @ 20,20 GET oGet VAR cSeek SIZE 160,20 PIXEL OF oDlg

       @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
          DATASOURCE "CUSTOMER" ;
          COLUMNS 1,2,3 ;
          HEADERS "Codice","Nome","Cognome" ;
          AUTOCOLS AUTOSORT CELL LINES NOBORDER

       WITH OBJECT oBrw
          :lIncrFilter   := .t.
          :cFilterFld    := aColumns[nField]
          :oSeek         := oGet // Required before :CreateFromCode()
          :CreateFromCode()
       END




      @ 20,  195 COMBOBOX oCbx Var oBrw:cFilterFld ;
               ITEMS {"Codice","Nome","Cognome"} ;
      SIZE 150,400 PIXEL OF oDlg HEIGHTGET 22

                         oCbx:bchange := <|Self|
                           nField:= ::nat
                           oBrw:cFilterFld := aColumns[nField]
                           Msginfo(oBrw:cFilterFld)            //
                           cSeek := Space( 100 )
                           oGet:refresh()
                           oBrw:Seek( "" )
                           oBrw:SetFocus()
                           oBrw:refresh()
                           oGet:setfocus()
                        return nil
                      >


       ACTIVATE DIALOG oDlg CENTERED

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby elvira » Tue Dec 29, 2020 9:29 pm

Hi,

With this feature, the filter is executed letter by letter or after the user press Enter?

Thanks
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: XBrowse: Using Get for incremental Seek/Filters

Postby nageswaragunupudi » Wed Dec 30, 2020 3:33 am

elvira wrote:Hi,

With this feature, the filter is executed letter by letter or after the user press Enter?

Thanks


letter by letter

Please build and run the sample I posted.
Regards

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby elvira » Wed Dec 30, 2020 8:06 am

How can be done to run the filter only when the user enters the whole string and press Enter?

Thank you.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: XBrowse: Using Get for incremental Seek/Filters

Postby Silvio.Falconi » Wed Dec 30, 2020 8:28 am

nageswaragunupudi wrote:
elvira wrote:Hi,

With this feature, the filter is executed letter by letter or after the user press Enter?

Thanks


letter by letter

Please build and run the sample I posted.


Nages,
I'm trying to use xbincflt.prg add your features


Image



I need to change text Header because

generally a header text is not inserted as the field name but can have a different text, so if we change the text of header column then make error

the example field:
Code: Select all  Expand view

-------------------------------------------------- -----------------------------------------------------
              index                                            tag / field                                  text column
-----------------------------------------------------------------------------------------------------------------

           UPPER (FIRST)                                   FIRST                                     NOME
           UPPER (LAST)                                     LAST                                      COGNOME
            UPPER (STREET)                                STREET                                  INDIRIZZO
            UPPER (CITY)                                      CITY                                      CITTA'
            UPPER (STATE)                                   STATE                                   STATO
            UPPER (ZIP)                                          ZIP                                       CAP
            HIREDATE                                            HIREDATE                              DATA DI ASSUNZIONE
            MARRIED                                             MARRIED                                 SPOSATO
            AGE                                                   AGE                                          ETA'

            SALARY                                             SALARY                                     STIPENDIO
            UPPER (NOTES)                                  NOTES                                      APPUNTI



 


Code: Select all  Expand view

#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,cheader
   local nChoice, uDataSource
   local cSeek := Space( 100 )
   local oGet

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

   cList := "First,Last,Street,State,HireDate"
   cheader := "Nome,Cognome,Indirizzo,Stato,Asssunzione"


   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 :=  HB_ATokens( cList, ',' )
   aHdrs :=  HB_ATokens( cheader, ',' )

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

   @ 11,160  GET oGet VAR cSeek SIZE 200,14 PIXEL OF oDlg

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

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

   @ 10, 10 COMBOBOX oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE (   CUST->(OrdSetFocus(::nat)),;
                     oBrw:cFilterFld:=aFlds[::nat],;
                     oBrw:Seek( "" ),;
                     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

   SWITCH nSource
   CASE 1
   CASE 3
      USE 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
      EXIT
   CASE 2
      oCn   := FW_OpenAdoConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ;
                                      cFilePath( GetModuleFileName() ) + ;
                                      "xbrtest.mdb;User Id=admin;Password=;" )
      if oCn != nil
         uSource  := FW_OpenRecordSet( oCn, "CUSTOMER" )
      endif
      EXIT
   DEFAULT
      QUIT
   END

return uSource

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

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby nageswaragunupudi » Wed Dec 30, 2020 3:43 pm

Records Selected
I add a first column to check, I saw if I select one customer then the print procedure print all customer
If I select two custoer then the print procedure print two customer ( selected)

Yes. We will address this issue soon.
Regards

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby nageswaragunupudi » Wed Dec 30, 2020 3:59 pm

As the name suggests, oBrw:cFilterFld is to be assigned with a Field Name, not cHeader of a column.
When the user selects a column in the combobox, you need to find of the name of the field used for that column and assign that name to oBrw:cFilterFld.
Regards

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

Re: XBrowse: Using Get for incremental Seek/Filters

Postby elvira » Wed Dec 30, 2020 4:13 pm

How can be done to run the filter only when the user enters the whole string and press Enter?

Thank you.
elvira
 
Posts: 516
Joined: Fri Jun 29, 2012 12:49 pm

Re: XBrowse: Using Get for incremental Seek/Filters

Postby nageswaragunupudi » Wed Dec 30, 2020 5:13 pm

elvira wrote:How can be done to run the filter only when the user enters the whole string and press Enter?

Thank you.


1. Use VALID clause for the Get: VALID oBrw:Seek( Trim( cSeek ) )
2. Remove the line :oSeek := oGet
Regards

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests