Add Xbrowse Column at runtime

Add Xbrowse Column at runtime

Postby Silvio.Falconi » Thu Nov 06, 2014 8: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

Image

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

Re: Add Xbrowse Column at runtime

Postby James Bott » Fri Nov 07, 2014 3:56 pm

Maybe you could just create the column at the start but specify a width of zero, then change the width at runtime.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Add Xbrowse Column at runtime

Postby Silvio.Falconi » Sun Nov 09, 2014 6: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 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: 6784
Joined: Thu Oct 18, 2012 7:17 pm

Re: Add Xbrowse Column at runtime

Postby James Bott » Sun Nov 09, 2014 7: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?
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Add Xbrowse Column at runtime

Postby Silvio.Falconi » Sun Nov 09, 2014 8: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 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: 6784
Joined: Thu Oct 18, 2012 7:17 pm

Re: Add Xbrowse Column at runtime

Postby nageswaragunupudi » Tue Nov 11, 2014 3: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
User avatar
nageswaragunupudi
 
Posts: 10253
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Add Xbrowse Column at runtime

Postby Silvio.Falconi » 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 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: 6784
Joined: Thu Oct 18, 2012 7:17 pm

Re: Add Xbrowse Column at runtime

Postby Silvio.Falconi » Wed Nov 12, 2014 12:02 pm

ok now i resolved it now run ok

First....

Image


then press the button

Image


@ 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
:lHscroll:=.F.
:lVscroll:=.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]:lHide:=!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 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: 6784
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Otto, SantaCroya and 17 guests