Page 1 of 1
xBrowse & array
Posted: Mon Dec 17, 2007 9:11 pm
by Robert Frank
Is it possible to choose columns of array to be displayed on xBrowse?
I have array of 20 elements.
I want to display only five of them in order 7,3,4,5,6
How to create this kind of xBrowse?
I don't want to create another separate array or put to every element oBRWKKPOD :aCols[xxx]:nWidth:=0 to do it.
Can I use oBrw:AddCol() or something simmilar?
Robert
Posted: Mon Dec 17, 2007 9:39 pm
by Otto
Hello Robert,
oBrw:aCols[3]:lHide = .t.
ACTIVATE WINDOW oChild ON INIT (oBrw:SwapCols( oBrw:aCols[1], oBrw:aCols[2] ), oBrw:SetFocus())
This is from FWH/SAMPLES/TESTXBRW.prg
I implemented the changes.
STATIC FUNCTION ArraySort( oWnd )
local oChild, oBrw, oCol
local aStruc
DEFINE WINDOW oChild TITLE "DBF structure with auto sort and incremental seek" MDICHILD OF oWnd
oBrw := TXBrowse():New( oWnd )
aStruc := DBStruct()
Aeval( aStruc, {|v| v[1] := Padr( v[1], 10 ) } )
oBrw:SetArray( aStruc, .t. )
oBrw:aCols[1]:cHeader := "NAME"
oBrw:aCols[2]:cHeader := "TYPE"
oBrw:aCols[2]:nDataStrAlign := AL_CENTER
oBrw:aCols[2]:nHeadStrAlign := AL_CENTER
oBrw:aCols[3]:cHeader := "SIZE"
oBrw:aCols[3]:nDataStrAlign := AL_RIGHT
oBrw:aCols[3]:nHeadStrAlign := AL_RIGHT
oBrw:aCols[3]:nHeadStrAlign := AL_RIGHT
oBrw:aCols[3]:lHide = .t.
oBrw:aCols[4]:cHeader := "LENGTH"
oBrw:aCols[4]:nDataStrAlign := AL_RIGHT
oBrw:aCols[4]:nHeadStrAlign := AL_RIGHT
oBrw:lHScroll := .f.
oBrw:lVScroll := .f.
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:CreateFromCode()
oChild:oClient := oBrw
ACTIVATE WINDOW oChild ON INIT (oBrw:SwapCols( oBrw:aCols[1], oBrw:aCols[2] ), oBrw:SetFocus())
RETURN NIL
Posted: Mon Dec 17, 2007 9:52 pm
by Robert Frank
Thank you Otto - it works!
Robert
Posted: Mon Dec 17, 2007 9:53 pm
by nageswaragunupudi
Here is how:
Code: Select all
oBrw := TXBrowse():New( oWnd )
oBrw:setArray( aData )
oBrw:aCols := {}
oCol := oBrw:AddCol()
oCol:bStrData := {||cValToChar( aData[oBrw:nArrayAt][7] )}
oCol := oBrw:AddCol()
oCol:bStrData := {||cValToChar( aData[oBrw:nArrayAt][3] )}
oCol := oBrw:AddCol()
oCol:bStrData := {||cValToChar( aData[oBrw:nArrayAt][4] )}
oCol := oBrw:AddCol()
oCol:bStrData := {||cValToChar( aData[oBrw:nArrayAt][5] )}
oCol := oBrw:AddCol()
oCol:bStrData := {||cValToChar( aData[oBrw:nArrayAt][6] )}
oBrw:CreateFromCode()
ownd:oClient := oBrw
ACTIVAE WINDOW oWnd
Posted: Mon Dec 17, 2007 9:56 pm
by Robert Frank
Nageswaragunupudi
It looks like my idea to create browser.
I'm going to implement it.
Thank you.
Robert
Posted: Mon Dec 17, 2007 10:12 pm
by Robert Frank
I implemented this code
oBRWKKPOD := TXBrowse():New( oDLGKKPOD )
oBRWKKPOD :SetArray( xTABAKT, .T. )
oBRWKKPOD :aCols := {}
oCol := oBRWKKPOD:AddCol()
oCol:bStrData := {||cValToChar( oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt][2] )}
oCol:cHeader := "Kod"
oCol:nWidth := 50
oCol:blDClickData := {|| (xKOD_K:=oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt,2],oDLGKKPOD:End()) }
oCol := oBRWKKPOD:AddCol()
oCol:bStrData := {||cValToChar( oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt][7] )}
oCol:cHeader := "Skrót"
oCol:nWidth := 150
oCol := oBRWKKPOD:AddCol()
oCol:bStrData := {||cValToChar( oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt][10] )}
oCol:cHeader := "Miasto"
oCol:nWidth := 100
oCol := oBRWKKPOD:AddCol()
oCol:bStrData := {||cValToChar( oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt][11] )}
oCol:cHeader := "Adres"
oCol:nWidth := 100
oCol := oBRWKKPOD:AddCol()
oCol:bStrData := {||cValToChar( oBRWKKPOD:aArrayData[oBRWKKPOD:nArrayAt][1] )}
oCol:cHeader := "Numer"
oCol:nWidth := 50
Looks very good, but I can't autosort this array.
I've used SetArray( xTABAKT, .T. ) but when I replaced original array to created in code I losed this function of xBrowse.
How to swith it on? Any idea?
Robert
Posted: Mon Dec 17, 2007 11:07 pm
by nageswaragunupudi
You can manually define bLClickHeader blocks. Alternatively, let all the columns be defined initially by SetArray method, including autosort.
Then hide the columns you dont want. ( eg. oBrw:aCols[n]:Hide() ).
You can also swap cols for repositioning them ( eg oBrw:SwapCols( 2,7 ) )
You can then get what you want
Posted: Mon Dec 17, 2007 11:20 pm
by Robert Frank
Otto and Nageswaragunupudi
Thank you for help.
I've just prepared design of browse what I looked for.
Robert