xBrowse on array - headers disappear.

xBrowse on array - headers disappear.

Postby Robert Frank » Wed Dec 05, 2007 5:52 pm

I have problem with xBrowse on array.
When I first time call a dialog with xBrowse all look correctly.
Image

but when I add one record to array headers disappear

Image

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
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby nageswaragunupudi » Wed Dec 05, 2007 6:19 pm

Please remove the line
oBRWF:SetArray( xTABBAD )
and try.
Regards

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

Postby Robert Frank » Wed Dec 05, 2007 6:30 pm

nageswaragunupudi wrote:Please remove the line
oBRWF:SetArray( xTABBAD )
and try.


I done it and happend nothing.
I saw headers but i didn't see my new record.

I have to use SetArray becouse I rebuild table and sort it by special order.
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby nageswaragunupudi » Wed Dec 05, 2007 8:17 pm

SetArray again recreates all the columns "without headers'

Can you post here lines of code creating the array first and then appending the row ?
Regards

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

Postby nageswaragunupudi » Wed Dec 05, 2007 8:43 pm

This is a working sample
Code: Select all  Expand view
#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

Please test this sample. It has to work and it works. Modify your code in the same manner.
Regards

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

Postby Robert Frank » Wed Dec 05, 2007 9:48 pm

nageswaragunupudi wrote:sample


Thank you for answer.
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
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby Robert Frank » Wed Dec 05, 2007 9:51 pm

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
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby Robert Frank » Wed Dec 05, 2007 9:52 pm

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.
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby Robert Frank » Wed Dec 05, 2007 9:53 pm

Post append:

Function APPEND_TO_TABLE()
.......
TABBAD_INIT(RR->RECNO)
oBRWF:SetArray( xTABBAD )
ODSWIEZ()
Return (NIL)

Static Function ODSWIEZ()
oBRWF:Refresh(.T.)
oBRWF:SetFocus()
Return .T.
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby Robert Frank » Wed Dec 05, 2007 9:54 pm

Nageswaragunupudi

What do you think, should it works?

R.
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby nageswaragunupudi » Wed Dec 05, 2007 10:54 pm

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
Code: Select all  Expand view
unction APPEND_TO_TABLE()
.......
TABBAD_INIT(RR->RECNO)

oBRWF:aArrayData := xTABBAD // oBRWF:SetArray( xTABBAD )

ODSWIEZ()
Return (NIL)


Pl see it fhis works
Regards

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

Postby Robert Frank » Wed Dec 05, 2007 10:58 pm

nageswaragunupudi wrote:Pl see it fhis works

You're GREAT

It works correctly.

Very,very thanks for it.

Robert
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland

Postby nageswaragunupudi » Wed Dec 05, 2007 11:01 pm

Glad it is working.
Nothing great, it is only that I've been using xbrowse for long
Regards

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

Postby Robert Frank » Wed Dec 05, 2007 11:06 pm

nageswaragunupudi wrote:Glad it is working.
Nothing great, it is only that I've been using xbrowse for long


I use it for week :(
Thank you
Robert Frank
User avatar
Robert Frank
 
Posts: 95
Joined: Fri Nov 23, 2007 4:43 am
Location: Gdynia-Poland


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests