xBrowse on array - headers disappear.
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
xBrowse on array - headers disappear.
I have problem with xBrowse on array.
When I first time call a dialog with xBrowse all look correctly.
but when I add one record to array headers disappear
After append on database I call this three lines
oBRWF:SetArray( xTABBAD )
oBRWF:Refresh(.T.)
oBRWF:SetFocus()
Any idea what I'm doing wrong?
R.
When I first time call a dialog with xBrowse all look correctly.
but when I add one record to array headers disappear
After append on database I call this three lines
oBRWF:SetArray( xTABBAD )
oBRWF:Refresh(.T.)
oBRWF:SetFocus()
Any idea what I'm doing wrong?
R.
Robert Frank
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
This is a working sample
Please test this sample. It has to work and it works. Modify your code in the same manner.
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
FUNCTION Main()
LOCAL oWnd, oBrw, oCol
LOCAL aArray, n
aArray := { { 1, 'AAA' }, { 2, 'BBB' }, { 3, 'CCC' } }
n := LEN( aArray ) // used to create append row
DEFINE WINDOW oWnd
oBrw := TXBrowse():New( oWnd )
oBrw:SetArray( aArray )
oBrw:aCols[1]:cHeader := 'First'
oBrw:aCols[2]:cHeader := 'Second'
// right click on browse appends a row
oBrw:bRClicked := {|| n++, ;
AADD( aArray, { n, REPLICATE(CHR(64+n),3) } ), ;
oBrw:Refresh(), ;
oBrw:GoBottom() ;
}
oBrw:CreateFromCode()
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd
RETURN NIL
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Thank you for answer.nageswaragunupudi wrote:sample
When I work on WINDOW my code working ok, but I want in on DIALOG.
Yours code work on dialog too, my blame is that I wanted to put another table instead original "in fly". xBrowse doesn't like it.
In TSBrowse I used methods DrawHeader and DrawFooter to correct this kind of situaction, I can't find something equal in xBrowse.
R.
Robert Frank
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Creating a browse:
Function LISTA_BADAN()
Local oBTN:=Array(20)
Local xPOZB:= 0
Local yPOZB:= 0
Local xPOZE:=800 // szerokosc
Local yPOZE:=550 // wysokosc
Local xRECT
Local oBRUSH
DEFINE BRUSH oBRUSH FILENAME "BACKGRND\TLO_DG.BMP"
DEFINE DIALOG oWNDF ;
FROM yPOZB,xPOZB TO yPOZE,xPOZE PIXEL ;
BRUSH oBRUSH ;
TITLE AllTrim(OemToAnsi(RR->NAZW))+' '+AllTrim(OemToAnsi(RR->IMIE))+' '+AllTrim(Str(RR->RECNO,8,0))+' / '+AllTrim(Str(RR->BARCODE,8,0))
Select("FF")
TABBAD_INIT(RR->RECNO)
oBRWF := TXBrowse():New( oWNDF )
oBRWF :SetArray( xTABBAD,.F.) // nie szukaj po badaniach
oBRWF :nHeaderLines := 2
oBRWF :nDataLines := 1
oBRWF :lFooter :=.t.
oBRWF :aCols[3]:cHeader := "Nazwa"+sCRLF+"badania"
oBRWF :aCols[3]:cFooter := "RAZEM : "
oBRWF :aCols[4]:cHeader := "Cena"+sCRLF+"badania"
oBRWF :aCols[4]:cFooter := Transform(nRABAT,"#####.##")
oBRWF :aCols[6]:cHeader := "Cena"+sCRLF+"amb."
oBRWF :aCols[6]:cFooter := Transform(nRAZEM,"#####.##")
oBRWF :aCols[5]:cHeader := "Pracownia"
oBRWF :aCols[5]:cFooter := IIF(nRAZEM=0,"",AllTrim(Transform(ABS((nRABAT/nRAZEM)*100-100),"#####.##"))+"%")
oBRWF :aCols[7]:cHeader := "Data i godzina akceptacji"
oBRWF :aCols[7]:cFooter := "-"
oBRWF :aCols[8]:cHeader := "Tube"
oBRWF :aCols[8]:cFooter := "-"
oBRWF :aCols[9]:cHeader := "Pozycja"
oBRWF :aCols[9]:cFooter := "-"
oBRWF :bClrHeader := {|| { nRGB(0,0,0), nRGB(222,227,247) } }
oBRWF :bClrFooter := oBRWF:bClrHeader
oBRWF :bClrStd := oBRWF:bClrHeader
oBRWF :nMarqueeStyle := MARQSTYLE_HIGHLROW
oBRWF :nColDividerStyle := LINESTYLE_DARKGRAY
oBRWF :nRowDividerStyle := LINESTYLE_DARKGRAY
oBRWF :nHeaderHeight :=50
oBRWF :CreateFromCode()
oBRWF :nTop = 22
oBRWF :nLeft = 0
oBRWF :nWidth = 600
oBRWF :nHeight =300
oBRWF:bKeyDown:={|nKEY| JAKIFFDown(nKEY) }
//oBRWF:bKeyChar:={|nKEY| JAKIFFChar(nKEY) }
@0, 0 BTNBMP oBTN[ 1] FILE "BMP\B_REB_1.BMP" OF oWNDF NOBORDER ;
ACTION (F_EDYCJA("N"),oBRWF:SetFocus())
oBTN[ 1]:cToolTip:="Dodaj badanie"
oBTN[ 1]:lTransparent:=.T.
@0, 20 BTNBMP oBTN[ 2] FILE "BMP\B_REB_2.BMP" OF oWNDF NOBORDER ;
ACTION (F_DODAJP(),oBRWF:SetFocus())
oBTN[ 2]:cToolTip:="Dodaj profil"
oBTN[ 2]:lTransparent:=.T.
@0, 40 BTNBMP oBTN[ 3] FILE "BMP\B_REB_3.BMP" OF oWNDF NOBORDER ;
ACTION (F_SKASUJ(),oBRWF:SetFocus())
oBTN[ 3]:cToolTip:=Ptxt("Usu~n badanie")
oBTN[ 3]:lTransparent:=.T.
@0, 60 BTNBMP oBTN[ 4] FILE "BMP\B_REB_4.BMP" OF oWNDF NOBORDER ;
ACTION FAKTURA()
oBTN[ 4]:cToolTip:="Wydruk faktury"
oBTN[ 4]:lTransparent:=.T.
@0, 80 BTNBMP oBTN[ 5] FILE "BMP\B_REB_5.BMP" OF oWNDF NOBORDER ;
ACTION DRUKUJ()
oBTN[ 5]:cToolTip:="Wydruk KP"
oBTN[ 5]:lTransparent:=.T.
@0,100 BTNBMP oBTN[ 6] FILE "BMP\B_REB_6.BMP" OF oWNDF NOBORDER ;
ACTION FISZKA()
oBTN[ 6]:cToolTip:=Ptxt("Wydruk przyj~etych zlece~n")
oBTN[ 6]:lTransparent:=.T.
@0,120 BTNBMP oBTN[ 7] FILE "BMP\B_REB_7.BMP" OF oWNDF NOBORDER ;
ACTION DAJ_RABAT()
oBTN[ 7]:cToolTip:=Ptxt("Udzielenie rabatu za wykonywane us~lugi")
oBTN[ 7]:lTransparent:=.T.
@0,140 BTNBMP oBTN[ 8] FILE "BMP\B_REB_8.BMP" OF oWNDF NOBORDER ;
ACTION COFNIJ_RABAT()
oBTN[ 8]:cToolTip:=Ptxt("Przywr~ocenie cen pierwotnych")
oBTN[ 8]:lTransparent:=.T.
@0,160 BTNBMP oBTN[ 9] FILE "BMP\ILOSC.BMP" OF oWNDF NOBORDER ;
ACTION ILOSC_BADAN()
oBTN[ 9]:cToolTip:=Ptxt("Ilo~s~c bada~n")
oBTN[ 9]:lTransparent:=.T.
@0,180 BTNBMP oBTN[10] FILE "BMP\B_REB_9.BMP" OF oWNDF NOBORDER ;
ACTION oWNDF:End()
oBTN[10]:cToolTip:=Ptxt("Zamkni~ecie bie~z~acego okna")
oBTN[10]:lTransparent:=.T.
@0,200 BTNBMP oBTN[11] FILE "BMP\DRUKKK.BMP" OF oWNDF NOBORDER ;
ACTION REJ_KK('',Str(RR->RECNO),{RR->NAZW,RR->IMIE},xTABBAD)
oBTN[11]:cToolTip:=Ptxt("Drukuj kod kreskowy dla punktu pobra~n")
oBTN[11]:lTransparent:=.T.
@0,220 BTNBMP oBTN[12] FILE "BMP\DRUKKKM.BMP" OF oWNDF NOBORDER ;
ACTION FF_WYDRUKUJ_KODY(RR->RECNO,RR->BARCODE,xTABBAD)
oBTN[12]:cToolTip:=Ptxt("Drukuj kody kreskowy dla zlecenia")
oBTN[12]:lTransparent:=.T.
If .NOT. CZY_MA_PRAWO(17)
oBTN[7]:Disable()
oBTN[8]:Disable()
oBTN[9]:Disable()
EndIf
ACTIVATE DIALOG oWNDF VALID ZWOLNIJ() ON INIT (ODSWIEZ(),oBRWF:SetSize( 799, 490 ),oBRWF:SetFocus()) CENTERED
Return NIL
Function LISTA_BADAN()
Local oBTN:=Array(20)
Local xPOZB:= 0
Local yPOZB:= 0
Local xPOZE:=800 // szerokosc
Local yPOZE:=550 // wysokosc
Local xRECT
Local oBRUSH
DEFINE BRUSH oBRUSH FILENAME "BACKGRND\TLO_DG.BMP"
DEFINE DIALOG oWNDF ;
FROM yPOZB,xPOZB TO yPOZE,xPOZE PIXEL ;
BRUSH oBRUSH ;
TITLE AllTrim(OemToAnsi(RR->NAZW))+' '+AllTrim(OemToAnsi(RR->IMIE))+' '+AllTrim(Str(RR->RECNO,8,0))+' / '+AllTrim(Str(RR->BARCODE,8,0))
Select("FF")
TABBAD_INIT(RR->RECNO)
oBRWF := TXBrowse():New( oWNDF )
oBRWF :SetArray( xTABBAD,.F.) // nie szukaj po badaniach
oBRWF :nHeaderLines := 2
oBRWF :nDataLines := 1
oBRWF :lFooter :=.t.
oBRWF :aCols[3]:cHeader := "Nazwa"+sCRLF+"badania"
oBRWF :aCols[3]:cFooter := "RAZEM : "
oBRWF :aCols[4]:cHeader := "Cena"+sCRLF+"badania"
oBRWF :aCols[4]:cFooter := Transform(nRABAT,"#####.##")
oBRWF :aCols[6]:cHeader := "Cena"+sCRLF+"amb."
oBRWF :aCols[6]:cFooter := Transform(nRAZEM,"#####.##")
oBRWF :aCols[5]:cHeader := "Pracownia"
oBRWF :aCols[5]:cFooter := IIF(nRAZEM=0,"",AllTrim(Transform(ABS((nRABAT/nRAZEM)*100-100),"#####.##"))+"%")
oBRWF :aCols[7]:cHeader := "Data i godzina akceptacji"
oBRWF :aCols[7]:cFooter := "-"
oBRWF :aCols[8]:cHeader := "Tube"
oBRWF :aCols[8]:cFooter := "-"
oBRWF :aCols[9]:cHeader := "Pozycja"
oBRWF :aCols[9]:cFooter := "-"
oBRWF :bClrHeader := {|| { nRGB(0,0,0), nRGB(222,227,247) } }
oBRWF :bClrFooter := oBRWF:bClrHeader
oBRWF :bClrStd := oBRWF:bClrHeader
oBRWF :nMarqueeStyle := MARQSTYLE_HIGHLROW
oBRWF :nColDividerStyle := LINESTYLE_DARKGRAY
oBRWF :nRowDividerStyle := LINESTYLE_DARKGRAY
oBRWF :nHeaderHeight :=50
oBRWF :CreateFromCode()
oBRWF :nTop = 22
oBRWF :nLeft = 0
oBRWF :nWidth = 600
oBRWF :nHeight =300
oBRWF:bKeyDown:={|nKEY| JAKIFFDown(nKEY) }
//oBRWF:bKeyChar:={|nKEY| JAKIFFChar(nKEY) }
@0, 0 BTNBMP oBTN[ 1] FILE "BMP\B_REB_1.BMP" OF oWNDF NOBORDER ;
ACTION (F_EDYCJA("N"),oBRWF:SetFocus())
oBTN[ 1]:cToolTip:="Dodaj badanie"
oBTN[ 1]:lTransparent:=.T.
@0, 20 BTNBMP oBTN[ 2] FILE "BMP\B_REB_2.BMP" OF oWNDF NOBORDER ;
ACTION (F_DODAJP(),oBRWF:SetFocus())
oBTN[ 2]:cToolTip:="Dodaj profil"
oBTN[ 2]:lTransparent:=.T.
@0, 40 BTNBMP oBTN[ 3] FILE "BMP\B_REB_3.BMP" OF oWNDF NOBORDER ;
ACTION (F_SKASUJ(),oBRWF:SetFocus())
oBTN[ 3]:cToolTip:=Ptxt("Usu~n badanie")
oBTN[ 3]:lTransparent:=.T.
@0, 60 BTNBMP oBTN[ 4] FILE "BMP\B_REB_4.BMP" OF oWNDF NOBORDER ;
ACTION FAKTURA()
oBTN[ 4]:cToolTip:="Wydruk faktury"
oBTN[ 4]:lTransparent:=.T.
@0, 80 BTNBMP oBTN[ 5] FILE "BMP\B_REB_5.BMP" OF oWNDF NOBORDER ;
ACTION DRUKUJ()
oBTN[ 5]:cToolTip:="Wydruk KP"
oBTN[ 5]:lTransparent:=.T.
@0,100 BTNBMP oBTN[ 6] FILE "BMP\B_REB_6.BMP" OF oWNDF NOBORDER ;
ACTION FISZKA()
oBTN[ 6]:cToolTip:=Ptxt("Wydruk przyj~etych zlece~n")
oBTN[ 6]:lTransparent:=.T.
@0,120 BTNBMP oBTN[ 7] FILE "BMP\B_REB_7.BMP" OF oWNDF NOBORDER ;
ACTION DAJ_RABAT()
oBTN[ 7]:cToolTip:=Ptxt("Udzielenie rabatu za wykonywane us~lugi")
oBTN[ 7]:lTransparent:=.T.
@0,140 BTNBMP oBTN[ 8] FILE "BMP\B_REB_8.BMP" OF oWNDF NOBORDER ;
ACTION COFNIJ_RABAT()
oBTN[ 8]:cToolTip:=Ptxt("Przywr~ocenie cen pierwotnych")
oBTN[ 8]:lTransparent:=.T.
@0,160 BTNBMP oBTN[ 9] FILE "BMP\ILOSC.BMP" OF oWNDF NOBORDER ;
ACTION ILOSC_BADAN()
oBTN[ 9]:cToolTip:=Ptxt("Ilo~s~c bada~n")
oBTN[ 9]:lTransparent:=.T.
@0,180 BTNBMP oBTN[10] FILE "BMP\B_REB_9.BMP" OF oWNDF NOBORDER ;
ACTION oWNDF:End()
oBTN[10]:cToolTip:=Ptxt("Zamkni~ecie bie~z~acego okna")
oBTN[10]:lTransparent:=.T.
@0,200 BTNBMP oBTN[11] FILE "BMP\DRUKKK.BMP" OF oWNDF NOBORDER ;
ACTION REJ_KK('',Str(RR->RECNO),{RR->NAZW,RR->IMIE},xTABBAD)
oBTN[11]:cToolTip:=Ptxt("Drukuj kod kreskowy dla punktu pobra~n")
oBTN[11]:lTransparent:=.T.
@0,220 BTNBMP oBTN[12] FILE "BMP\DRUKKKM.BMP" OF oWNDF NOBORDER ;
ACTION FF_WYDRUKUJ_KODY(RR->RECNO,RR->BARCODE,xTABBAD)
oBTN[12]:cToolTip:=Ptxt("Drukuj kody kreskowy dla zlecenia")
oBTN[12]:lTransparent:=.T.
If .NOT. CZY_MA_PRAWO(17)
oBTN[7]:Disable()
oBTN[8]:Disable()
oBTN[9]:Disable()
EndIf
ACTIVATE DIALOG oWNDF VALID ZWOLNIJ() ON INIT (ODSWIEZ(),oBRWF:SetSize( 799, 490 ),oBRWF:SetFocus()) CENTERED
Return NIL
Robert Frank
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
Initialisation of table
Static Function TABBAD_INIT(xRECNO)
nRABAT:=0
nRAZEM:=0
xTABBAD:={{0,0,'Brak danych','-','-','-','-',0,0}}
If FF->(DbSeek(xRECNO))
xTABBAD:={}
Do While FF->RECNO=xRECNO .AND. .NOT. FF->(Eof())
AADD(xTABBAD,{;
FF->NR_G,;
FF->NR_T,;
OemToAnsi(FF->NAZWA),;
Str(FF->ILOSC*FF->CENA_S,8,2),;
Get_Naz_Pra(FF->NR_S),;
Str(FF->ILOSC*GET_xTABCENN(FF->NR_T,4),8,2),;
DToC(FF->A_DATA)+FF->A_TIME,;
5->PROBOWKA,;
FF->POZYCJA }) // zeby dobrze sortowal w czasie rejestracji
nRABAT+=FF->ILOSC*FF->CENA_S
nRAZEM+=FF->ILOSC*GET_xTABCENN(FF->NR_T,4)
FF->(DbSkip(1))
EndDo
FF->(DbSeek(xRECNO))
Else
FF->(DbGoTop())
EndIf
cRABAT:=Str(nRABAT,8,2)
cRAZEM:=Str(nRAZEM,8,2)
// tutaj posortowac tak jak bedzie na wydruku
xTABBAD:=ASORT(xTABBAD,,,{ |X,Y| x[9]<y[9] })
Return .T.
Static Function TABBAD_INIT(xRECNO)
nRABAT:=0
nRAZEM:=0
xTABBAD:={{0,0,'Brak danych','-','-','-','-',0,0}}
If FF->(DbSeek(xRECNO))
xTABBAD:={}
Do While FF->RECNO=xRECNO .AND. .NOT. FF->(Eof())
AADD(xTABBAD,{;
FF->NR_G,;
FF->NR_T,;
OemToAnsi(FF->NAZWA),;
Str(FF->ILOSC*FF->CENA_S,8,2),;
Get_Naz_Pra(FF->NR_S),;
Str(FF->ILOSC*GET_xTABCENN(FF->NR_T,4),8,2),;
DToC(FF->A_DATA)+FF->A_TIME,;
5->PROBOWKA,;
FF->POZYCJA }) // zeby dobrze sortowal w czasie rejestracji
nRABAT+=FF->ILOSC*FF->CENA_S
nRAZEM+=FF->ILOSC*GET_xTABCENN(FF->NR_T,4)
FF->(DbSkip(1))
EndDo
FF->(DbSeek(xRECNO))
Else
FF->(DbGoTop())
EndIf
cRABAT:=Str(nRABAT,8,2)
cRAZEM:=Str(nRAZEM,8,2)
// tutaj posortowac tak jak bedzie na wydruku
xTABBAD:=ASORT(xTABBAD,,,{ |X,Y| x[9]<y[9] })
Return .T.
Robert Frank
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Everytime you are appending you are recreating the array. Better would be to modify the same array whose reference the browse object knows.
Once you SetArray in the beginning pl dont use it again. SetArray removes all existing columns and creates all columns again without headers.
Please try this change
Pl see it fhis works
Once you SetArray in the beginning pl dont use it again. SetArray removes all existing columns and creates all columns again without headers.
Please try this change
Code: Select all
unction APPEND_TO_TABLE()
.......
TABBAD_INIT(RR->RECNO)
oBRWF:aArrayData := xTABBAD // oBRWF:SetArray( xTABBAD )
ODSWIEZ()
Return (NIL)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Robert Frank
- Posts: 95
- Joined: Fri Nov 23, 2007 4:43 am
- Location: Gdynia-Poland
- Contact: