the Dbf have two Field GeMateria, GepClave all to 40/45 Cr
- Code: Select all Expand view
- function BuildTree( oTree,nTipo )
local oLink1, oLink2
DEFAULT ntipo := 1
SELECT GE
GE->(DbGoTop())
IF ntipo=1
DO WHILE ! GE->(EOF())
if Rtrim(GE->GEPClave) == ""
oLink1 := oTree:Add(GE->GEMATERIA,0)
oLink1:Cargo := Upper(GE->GEMATERIA)
oTree:Cargo := GE->GEMATERIA
else
oLink2 := oLink1:Add(GE->GEPClave,1)
oLink2:Cargo := Upper(GE->GEMATERIA) + Upper(GE->GEPClave)
endif
GE->(DbSkip())
ENDDO
elseif ntipo=2
DO WHILE ! GE->(EOF())
if Rtrim(GE->GEPClave) == ""
oLink1 := oTree:Add(GE->GEMATERIA,0)
oLink1:Cargo := Upper(GE->GEMATERIA)
oTree:Cargo := GE->GEMATERIA
Endif
GE->(DbSkip())
ENDDO
Endif
oTree:SetFocus()
return nil
How Converte to xbrowse tree , any solution ?
I made this ( ad the sample test xbrwtree.prg)
- Code: Select all Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
function Main()
local oWnd, oBrw
CreateSampleDbf()
USE GRUENT ALIAS GE
INDEX ON UPPER(GE->GEMATERIA)+UPPER(GE->GEPCLAVE) TAG GE01 FOR !Deleted()
INDEX ON UPPER(GE->GEMATERIA) TAG GE02 FOR ((!DELETED()) )
INDEX ON UPPER(GE->GEPCLAVE) TAG GE03 FOR ((!DELETED()) )
GE->(DbSetOrder(1))
DEFINE WINDOW oWnd TITLE " tree with XBrowse"
@ 0, 0 XBROWSE oBrw OF oWnd LINES CELL
oBrw:SetTree( BuildTree(), { "open", "close", "go" } )
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 1 ] HEADER "Categoria"
ADD TO oBrw DATA oBrw:oTreeItem:Cargo[ 2 ] HEADER "Sottocategoria"
oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrw:CreateFromCode()
oBrw:aCols[ 1 ]:cHeader = "Categoria"
oWnd:oClient = oBrw
ACTIVATE WINDOW oWnd
return nil
static function BuildTree()
local oTree, cState
TREE oTree
while ! Eof()
if Empty( cState )
_TreeItem( GE->GEMATERIA ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
cState = GE->GEMATERIA
else
if cState != GE->GEMATERIA
ENDTREE
cState = GE->GEMATERIA
_TreeItem( GE->GEMATERIA ):Cargo := { Space( 20 ), Space( 20 ) }
TREE
endif
endif
if GE->GEMATERIA == cState
_TreeItem( GE->GEPCLAVE ):Cargo := { GE->GEMATERIA, GE->GEPCLAVE }
endif
SKIP
enddo
ENDTREE
ENDTREE
GO TOP
return oTree
Function CreateSampleDbf()
DbCreate('GE', {{'GEMATERIA' , 'C', 40, 0} ,;
{'GEPCLAVE' , 'C', 45, 0} ,;
{'MAEJEMPL' , 'N', 5, 0}}, 'DBFCDX')
close all
use &('GE') new
select GE
if FILE('GRUENT.DBF')
delete file &('GRUENT.cdx')
append from &('GRUENT')
dbcommitall()
close all
delete file &('GRUENT.dbf')
endif
close all
rename &('GE.dbf') to &('GRUENT.dbf')
return nil
But not run as I wanted
I have this
But where is the other categories ?