FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Add Xbrowse Column at runtime
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Add Xbrowse Column at runtime
Posted: Thu Nov 06, 2014 08:26 AM
Can I insert a column on a X pos at runtime and make calc math for it ?

sample I wish insert a checkbox column after X columns and if the user click on if must calc an math operation refresh another column

for a sample look this picture



I wish insert a column at the red arrow amd calc the percentual 20% on the column "Importo"
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Add Xbrowse Column at runtime
Posted: Fri Nov 07, 2014 03:56 PM

Maybe you could just create the column at the start but specify a width of zero, then change the width at runtime.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Add Xbrowse Column at runtime
Posted: Sun Nov 09, 2014 06:11 PM

No,
I think ( and I found it on this forum) I can make a function type

Function Addcolumn()
ADD TO oBrw AT 8 DATA oBrw:Rit HEADER "SlNo"
oBrw:Rit:setcheck()
return nil

where Rit ia a field .... but it not run here!!!

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Add Xbrowse Column at runtime
Posted: Sun Nov 09, 2014 07:07 PM

ADD TO oBrw AT 8 DATA oBrw:Rit HEADER "SlNo"
oBrw:Rit:setcheck()

There are two problems. Rit is not data of oBrw, and fields don't have methods, so you can't do oBrw:Rit:setcheck().

There is a setCheck() method of oBrw but it has to do with bitmaps.

METHOD SetCheck( aBmps, uEdit, aPrompts ) CLASS TXBrowse

Maybe you should review the original posting showing the code you posted.

Did you try my previous suggestion?

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Add Xbrowse Column at runtime
Posted: Sun Nov 09, 2014 08:47 PM

James the setcheck is not important !! I Know there are two bmps. If you see testxbrowse sample there is a field maried

oCol  := oBrw:oCol( "Married" )

oCol:SetCheck( { "GREEN", "RED" }, {|o, v| (DBRLOCK(), _FIELD->Married := v, DBUNLOCK() ) } )
oCol:bStrData := { || If( _FIELD->Married, "Yes", "No" ) }
oCol:nDataStrAlign := AL_RIGHT

Rit is a field of the same archive of xbrowse

on init there is not the column and the final user can insert it on runtime because for one document it is not important while for other it is need (order,invoice,quote...)

and if the user check this colums the procedure must calc an specific oeration on Total od Import of invoice

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Add Xbrowse Column at runtime
Posted: Tue Nov 11, 2014 03:17 PM

ADD TO oBrw AT 8 ............
is the right way.

But I am not sure what you want to display in the inserted column and what other column you want to change and refresh.

If you just want to display 20% of the value in Importo column, you can do this

ADD TO oBrw AT 8 DATA (oBrw:Importo:Value * 0.20) TITLE "New" PICTURE "9999.99"

If you want some other display and some other action, we can incorporate the same

Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Add Xbrowse Column at runtime
Posted: Wed Nov 12, 2014 10:41 AM

Mr Nages,

I try to explain you

I wish only insert a column with checkbox.... from user

the user can insert this column check but at init when I create the xbrowse it must no showed

then..

on my Function of Totals I musst be able to Know if that record at that column is check .

If it check I must calc the new import ( sample nImporto+20%)

I made

@x,y button ...action Ins_Ritenuta(oBrw)

Function Ins_Ritenuta(oBrw)

  WITH OBJECT oBrw:InsCol( 8 )
  :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
  :SetCheck()
  :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
  :cHeader       := "Rit."

END

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

but it make errors

I tried also with

              WITH OBJECT oBrw:InsCol( 8 )
                    :lHide      :=  lRitenuta
                    :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
                    :SetCheck()
                    :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
                    :cHeader       := "Rit."
                 END

at the init lRitenuta is false

the the use can press a button and change lritenuta

@x,y button ACTION ( lRitenuta:=IF(lRitenuta,.f.,.t.), oBrw:refresh() )

the browse is not refreshed

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Add Xbrowse Column at runtime
Posted: Wed Nov 12, 2014 12:02 PM
ok now i resolved it now run ok

First....




then press the button




@ x,y Xbrowse....


WITH OBJECT oBrw

WITH OBJECT oBrw:InsCol( 8 )
:lHide := !lRitenuta
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck()
:nHeadBmpNo := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
:cHeader := "Rit."
END


:lFastEdit = .T.
:nStretchCol := STRETCHCOL_WIDEST
:=.F.
:=.T.
:lRecordSelector := .F.
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nColDividerStyle := LINESTYLE_LIGHTGRAY



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


END





@10,10 button .... action lRitenuta:=IF(lRitenuta,.f.,.t.),;
oBrw:aCols[8]:=!lRitenuta, oBrw:refresh()


the problem : I not see the last header of Importo

and I wish if it possble check all when the user set the lritenuta
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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

Continue the discussion