Como dice el encabezado, requiero cambiar el tipo de datos que se muestra en un xbrowse, inicialmente cargamos un tree, pero quiero poder cambiarlo por un array. Tambien cambiar la cantidad de columnas que se muestran.
Dejo este código para ver si pueden ayudarme, espero haberme hecho entender, de antemano gracias
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw
local oTree , oBtn
local aOther := {}
local hLine := {=>}
local aCols := {"Code","Name","Cant","Value"}
local aCol2 := {"cod","name","cant","value"}
local cbChange := <||
oBrw:nDataType := DATATYPE_ARRAY
oBrw:SetArray( aOther, nil, nil, aCol2 )
oBrw:refresh()
msginfo("finish")
>
hLine["cod"] := "001"
hLine["name"] := "First"
hLine["cant"] := 1
hLine["value"] := 15
AADD(aOther,hLine)
hLine := {=>}
hLine["cod"] := "002"
hLine["name"] := "Second"
hLine["cant"] := 2
hLine["value"] := 54
AADD(aOther,hLine)
hLine := {=>}
hLine["cod"] := "001"
hLine["name"] := "Third"
hLine["cant"] := 9
hLine["value"] := 77
AADD(aOther,hLine)
hLine := {=>}
USE Customer
INDEX ON Field->State TO State
SET ORDER TO "State"
GO TOP
DEFINE WINDOW oWnd TITLE "Cambiando el tipo de datos xbrowse"
oTree := BuildTree()
@ 10,10 BUTTONBMP oBtn OF oWnd PIXEL size 60, 30 PROMPT "Cambiar" ACTION EVAL(cbChange)
@ 50,0 XBROWSE oBrw OF oWnd ;
LINES STYLE FLAT NOBORDER ;
DATASOURCE oTree COLUMNS 1,2,3 ;
HEADERS "State & City", "Last", "First" PIXEL
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
cState = Customer->State
else
if cState != Customer->State
ENDTREE
cState = Customer->State
_TreeItem( Customer->State ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
endif
endif
if Customer->State == cState
_TreeItem( Customer->City ):Cargo := { Customer->Last, Customer->First }
endif
SKIP
enddo
ENDTREE
ENDTREE
oTree:OpenAll()
GO TOP
return oTree