xbgetbar

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

xbgetbar

Post by Silvio.Falconi »

the sample xbgetbar run ok

Image

I wish ask only 3 questions
1) have a sample with one column ( for a sample only city field)

sample :

@ 60, 5 XBROWSE oBrowse OF oTabella ;
SIZE -5,200 PIXEL FONT oFontTabella


oCol := oBrowse:AddCol()
oCol:bStrData := { || customer->city }
oCol:cHeader :="City"
oCol:nWidth := 250





2) is it possible that when I insert a letter the procedure already looks for the records that have that letter? obviously without pressing the "set filter" button?
3) is it possible to have the option to insert a btnbmp in the get field so that I can call the clearfilter function without pressing the button?

sample :
Image


I tried to make it , so I haven't figured out how to build the search dialog yet

Image

Code: Select all

static function Sample1()

   local oDlg, oBrw, oFont, oBold
   local n

   USE CUSTOMER NEW SHARED

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

   DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL ;
      FONT oFont TITLE FWVERSION + " : Bar Get"
@ 110,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
       CELL LINES NOBORDER    

   oCol := oBrw:AddCol()
oCol:bStrData := { || customer->city }
oCol:cHeader :="City"
oCol:nWidth := 250
 oCol:uBarGetVal    := space(10)

  WITH OBJECT oBrw
      :nHeaderHeight    := 40 // optional
      :oHeaderFonts     := oBold
      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW } }
      :AutoFit()
      //
      :CreateFromCode()
   END

   @ 10,20 SAY "Gets under Headers. Entered values can be used" + ;
      "for filtering or any othe purpose" + CRLF + ;
      "Usage: oCol:uBarGetVal := Space( 10 ); oBrw:lGetBar := .t." ;
      SIZE oDlg:nWidth - 40,40 PIXEL OF oDlg CENTER

   @ 60, 20 BTNBMP PROMPT { || If( oBrw:lGetBar, "Hide GetBar", "ShowGetBar" ) } ;
      SIZE 100,40 PIXEL OF oDlg FLAT ;
      ACTION ( oBrw:lGetBar := ! oBrw:lGetBar, oBrw:Refresh() )

   @ 60,140 BTNBMP PROMPT "Set Filter" ;
      SIZE 100,40 PIXEL OF oDlg FLAT ;
      ACTION ( oBrw:cAlias )->( SetFilter( oBrw ) )

   @ 60,250 BTNBMP PROMPT "Clear Filter" ;
      SIZE 100,40 PIXEL OF oDlg FLAT ;
      ACTION ( oBrw:cAlias )->( DBCLEARFILTER(), oBrw:Refresh(), oBrw:SetFocus() )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont, oBold

return nil
SomeOne can Help me pls ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: xbgetbar

Post by Silvio.Falconi »

Now I tried with

oBrw:lGetBar := .t.
oBrw:nGetBarHeight:=33

oBrw:aCols[1]:uBarGetVal := Space(60)
oBrw:aCols[1]:cBarGetBmp := "cancella.bmp"
oBrw:aCols[1]:bBarGetAction := {|| (oBrw: cAlias) -> (SetFilter(oBrw,1,5))}

1 = first column on the browse
5 := the field number on the dbf

and changed the function

Code: Select all

 

 static function SetFilter( oBrw,nColumn,nField)

   local cFilter := ""
   local  oCol, uVal, cType

  // for n := 1 to Len( oBrw:aCols )
      oCol  := oBrw:aCols[ nColumn ]
      if ! Empty( uVal := oCol:uBarGetVal )
         if !Empty( cFilter )
            cFilter  += " .AND. "
         endif
         cType    := ValType( uVal )
              * ?n
         do case
         case cType == 'C'
            uVal     := Upper( AllTrim( uVal ) )
            cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( nField ) + " )"
         otherwise
            cFilter  += FieldName( nField ) + " == " + cValToChar( uVal )
         endcase
      endif

  // next

   if Empty( cFilter )
      if ! Empty( DBFILTER() )
         DBCLEARFILTER()
         oBrw:Refresh()
      endif
   else
      if !( DBFILTER() == cFilter )
         SET FILTER TO &cFilter
         GO TOP
         oBrw:Refresh()
      endif
   endif

   oBrw:SetFocus()

return nil
 
Is there a solution without going to change the setfilter function every time?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: xbgetbar

Post by Silvio.Falconi »

If we use the Rao sample and I wish show two columns

@ 110,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
CELL LINES NOBORDER

oCol := oBrw:AddCol()
oCol:bStrData := { || upper(customer->city) }
oCol:cHeader :="City"
oCol:nWidth := 250

oCol := oBrw:AddCol()
oCol:bStrData := { || upper(customer->first) }
oCol:cHeader :="first"
oCol:nWidth := 250

Image

the procedure always looks for the customer ID field in the first column of the xbrowse and the customer First field in the second column

thus creating an error for the first column

that is, I do not understand why the procedure looks for the first field of the database if I have inserted another field in the column
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply