xBrowse & array

xBrowse & array

Postby Robert Frank » Mon Dec 17, 2007 9:11 pm

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

Postby Otto » Mon Dec 17, 2007 9:39 pm

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
User avatar
Otto
 
Posts: 6327
Joined: Fri Oct 07, 2005 7:07 pm

Postby Robert Frank » Mon Dec 17, 2007 9:52 pm

Thank you Otto - it works!

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

Postby nageswaragunupudi » Mon Dec 17, 2007 9:53 pm

Here is how:
Code: Select all  Expand view
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
Regards

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

Postby Robert Frank » Mon Dec 17, 2007 9:56 pm

Nageswaragunupudi

It looks like my idea to create browser.
I'm going to implement it.

Thank you.

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

Postby Robert Frank » Mon Dec 17, 2007 10:12 pm

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

Postby nageswaragunupudi » Mon Dec 17, 2007 11:07 pm

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
Regards

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

Postby Robert Frank » Mon Dec 17, 2007 11:20 pm

Otto and Nageswaragunupudi
Thank you for help.

I've just prepared design of browse what I looked for.

Robert
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 93 guests