Xbrowse Tree using Array instead of DBF

Xbrowse Tree using Array instead of DBF

Postby fraxzi » Tue Dec 06, 2011 8:52 am

Hi!

It's been a while since I posted but almost everyday I read topics here..

I usually do xbrowse tree using DBF data..

I couldn't find an example using Array data for an xbrowse tree.. anyone? .. Mr. RAO?


Kind Regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Xbrowse Tree using Array instead of DBF

Postby anserkk » Tue Dec 06, 2011 10:33 am

Try this.
Image
Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()

    Local oBrw,oWnd
   
    DEFINE WINDOW oWnd TITLE "Tree using Array"
    @0,0 XBROWSE oBrw OF oWnd
   
    WITH OBJECT oBrw
      :SetTree(BuildTree())
      :oTree:OpenAll()
      :CreateFromCode()
    END
   
    oWnd:oClient:=oBrw
    ACTIVATE WINDOW oWnd
Return NIL

//---------------------//
Function BuildTree()

    Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
    Local i,j
    Local aItems:={ {"01","Computers"      ,0},;
                    {"02","Core i3"        ,1},;
                    {"03","Core i5"        ,1},;  
                    {"04","Furnitures"     ,0},;
                    {"05","Tables"         ,1},;  
                    {"06","Computer Table" ,2},;
                    {"07","Regular Table"  ,2},;                    
                    {"08","Desk"           ,1},;
                    {"09","Computer Desk"  ,2},;                    
                    {"10","Regular Desk"   ,2},;                    
                    {"11","Chairs"         ,1} }  
                   
    TREE oTree  
    nLevel:=aItems[1][3]
    nTreeCount:=0            
    For i:=1 to Len(aItems)
        if aItems[i][3] > nLevel
            TREE
            nTreeCount++
        Elseif aItems[i][3] < nLevel
            nPrevLevel:=nLevel
            nCurLevel:=aItems[i][3]
            nLevelDiff:=nPrevLevel-nCurLevel
            For j:=1 to nLevelDiff
                ENDTREE
                nTreeCount--
            Next
        Endif    
        TREEITEM aItems[i][2] CARGO { aItems[i][1] }  // Item Code
        nLevel:=aItems[i][3]
    Next              
    if nTreeCount > 0
       For i:=nTreeCount To 1 Step -1
          ENDTREE
       Next
    Endif        
    ENDTREE
Return oTree


Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Xbrowse Tree using Array instead of DBF

Postby RAMESHBABU » Tue Dec 06, 2011 3:01 pm

Hello Anser,

Very Good Example :D

Regards,

- Ramesh
User avatar
RAMESHBABU
 
Posts: 626
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Re: Xbrowse Tree using Array instead of DBF

Postby fraxzi » Wed Dec 07, 2011 12:04 am

Hi Anser!

That's a good one!


Kind regards,
Frances
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Xbrowse Tree using Array instead of DBF

Postby ACC69 » Tue Jul 24, 2012 9:58 pm

anserkk wrote:Try this.
Image
Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()

    Local oBrw,oWnd
   
    DEFINE WINDOW oWnd TITLE "Tree using Array"
    @0,0 XBROWSE oBrw OF oWnd
   
    WITH OBJECT oBrw
      :SetTree(BuildTree())
      :oTree:OpenAll()
      :CreateFromCode()
    END
   
    oWnd:oClient:=oBrw
    ACTIVATE WINDOW oWnd
Return NIL

//---------------------//
Function BuildTree()

    Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
    Local i,j
    Local aItems:={ {"01","Computers"      ,0},;
                    {"02","Core i3"        ,1},;
                    {"03","Core i5"        ,1},;  
                    {"04","Furnitures"     ,0},;
                    {"05","Tables"         ,1},;  
                    {"06","Computer Table" ,2},;
                    {"07","Regular Table"  ,2},;                    
                    {"08","Desk"           ,1},;
                    {"09","Computer Desk"  ,2},;                    
                    {"10","Regular Desk"   ,2},;                    
                    {"11","Chairs"         ,1} }  
                   
    TREE oTree  
    nLevel:=aItems[1][3]
    nTreeCount:=0            
    For i:=1 to Len(aItems)
        if aItems[i][3] > nLevel
            TREE
            nTreeCount++
        Elseif aItems[i][3] < nLevel
            nPrevLevel:=nLevel
            nCurLevel:=aItems[i][3]
            nLevelDiff:=nPrevLevel-nCurLevel
            For j:=1 to nLevelDiff
                ENDTREE
                nTreeCount--
            Next
        Endif    
        TREEITEM aItems[i][2] CARGO { aItems[i][1] }  // Item Code
        nLevel:=aItems[i][3]
    Next              
    if nTreeCount > 0
       For i:=nTreeCount To 1 Step -1
          ENDTREE
       Next
    Endif        
    ENDTREE
Return oTree


Regards
Anser



Hola buenas tardes Anserk,como esta, estoy tratando de compilar tu ejemplo, pero me marca error,que es lo que hace falta,uso version 8.12

//---------------------//
Function BUSCAR1()

Local oBrw,oWnd

DEFINE WINDOW oWnd TITLE "Tree using Array"
@0,0 XBROWSE oBrw OF oWnd

WITH OBJECT oBrw
:SetTree(BuildTree())
:oTree:OpenAll()
:CreateFromCode()
END

oWnd:oClient:=oBrw
ACTIVATE WINDOW oWnd
Return NIL

//---------------------//
Function BuildTree()

Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
Local i,j,nLevel
Local aItems:={ {"01","Computers" ,0},;
{"02","Core i3" ,1},;
{"03","Core i5" ,1},;
{"04","Furnitures" ,0},;
{"05","Tables" ,1},;
{"06","Computer Table" ,2},;
{"07","Regular Table" ,2},;
{"08","Desk" ,1},;
{"09","Computer Desk" ,2},;
{"10","Regular Desk" ,2},;
{"11","Chairs" ,1} }

TREE oTree
nLevel:=aItems[1][3]
nTreeCount:=0
For i:=1 to Len(aItems)
if aItems[i][3] > nLevel
TREE
nTreeCount++
Elseif aItems[i][3] < nLevel
nPrevLevel:=nLevel
nCurLevel:=aItems[i][3]
nLevelDiff:=nPrevLevel-nCurLevel
For j:=1 to nLevelDiff
ENDTREE
nTreeCount--
Next
Endif
TREEITEM aItems[i][2] CARGO { aItems[i][1] } // Item Code
nLevel:=aItems[i][3]
Next
if nTreeCount > 0
For i:=nTreeCount To 1 Step -1
ENDTREE
Next
Endif
ENDTREE
Return oTree

Este es el error :

C:\Pro_FWH\ProveIVA\Prg\buscar1.prg(70) Error E0030 Syntax error: "syntax
error at 'AITEMS'"

Estoy tratando de adaptar a mi catalago de cuentas de 1 a 4 niveles de cuentas con caracter y longitud 16 ,y estaba tomando tu ejemplo, pero no me sale desde mi dbfs.

Saludos y buen dia.

Atte: Adrian C. C.
ACC69
 
Posts: 632
Joined: Tue Dec 12, 2006 7:34 pm

Re: Xbrowse Tree using Array instead of DBF

Postby anserkk » Wed Jul 25, 2012 7:01 am

Sorry,
I cannot find line 70 in your code. As per your message, the error occurs at line 70. The max no of lines in the code posted by you is only 61.

Did you try the sample code posted by me on your PC using your FHW ver 8.12 ?. Did it work ?

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Xbrowse Tree using Array instead of DBF

Postby ACC69 » Wed Jul 25, 2012 2:02 pm

anserkk wrote:Sorry,
I cannot find line 70 in your code. As per your message, the error occurs at line 70. The max no of lines in the code posted by you is only 61.

Did you try the sample code posted by me on your PC using your FHW ver 8.12 ?. Did it work ?

Regards
Anser


Hola buenos dias de nuevo, el error se produce aqui en esta linea ....

For i:=1 to Len(aItems)
if aItems[i][3] > nLevel
TREE
nTreeCount++
Elseif aItems[i][3] < nLevel
nPrevLevel:=nLevel
nCurLevel:=aItems[i][3]
nLevelDiff:=nPrevLevel-nCurLevel
For j:=1 to nLevelDiff
ENDTREE
nTreeCount--
Next
Endif
TREEITEM aItems[i][2] CARGO { aItems[i][1] } // Item Code /// Anserk aqui se me produce este error, y es con tu codigo que estoy probando....
nLevel:=aItems[i][3]
Next

Quiero implementar mi catalogo de cuentas en forma de tree,mi estructura en la base de datos es asi : Cuentas caracter longitud 16 y nivel longitud 1 numerico

CUENTAS NIVEL DESCRIPCION

1020-0000-0000-0000 1 Cuenta mayor
1020-0001-0000-0000 2 Subcta
1020-0001-0001-0000 3 Subsubcta
1020-0001-0001-0001 4 subsubctanddetalles

Pero como hacerle con tu ejemplo, que intento compilar, pero ese error me sigue dando, y es el mismo ejemplo con tu codigo, solo le agregue la variable nLevel, que no estaba declarado,uso VERCE 5.0 y FWH 8.12

Saludos y buen dia Anserk

Atte: Adrian C. C.
ACC69
 
Posts: 632
Joined: Tue Dec 12, 2006 7:34 pm

Re: Xbrowse Tree using Array instead of DBF

Postby Otto » Wed Jul 25, 2012 2:48 pm

I use normal xBrowse with

oBrw:bIndent := { ||20 + ( ::cAlias )->TREELEVEL * 20 }

instead of treeView.

Best regards,
Otto

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Xbrowse Tree using Array instead of DBF

Postby anserkk » Thu Jul 26, 2012 4:55 am

To do a test with your FWH ver, I don't have FWH 8.12 here with me right now.

Many changes has been implemented to Tree after Ver 8.12

Anyway Tree with your data is working fine here with the latest FWH version.

CUENTAS NIVEL DESCRIPCION
1020-0000-0000-0000 1 Cuenta mayor
1020-0001-0000-0000 2 Subcta
1020-0001-0001-0000 3 Subsubcta
1020-0001-0001-0001 4 subsubctanddetalles

Image

Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()

    Local oBrw,oWnd
   
    DEFINE WINDOW oWnd TITLE "Tree using Array"
    @0,0 XBROWSE oBrw OF oWnd
   
    WITH OBJECT oBrw
      :SetTree(BuildTree())
      :oTree:OpenAll()
      :CreateFromCode()
    END
   
    oWnd:oClient:=oBrw
    ACTIVATE WINDOW oWnd
Return NIL

//---------------------//
Function BuildTree()

    Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
    Local i,j
/*    Local aItems:={ {"01","Computers"      ,0},;
                    {"02","Core i3"        ,1},;
                    {"03","Core i5"        ,1},;  
                    {"04","Furnitures"     ,0},;
                    {"05","Tables"         ,1},;  
                    {"06","Computer Table" ,2},;
                    {"07","Regular Table"  ,2},;                    
                    {"08","Desk"           ,1},;
                    {"09","Computer Desk"  ,2},;                    
                    {"10","Regular Desk"   ,2},;                    
                    {"11","Chairs"         ,1} }  
*/
                   
Local aItems:={ {"1020-0000-0000-0000", 1,"Cuenta mayor"},;
                {"1020-0001-0000-0000", 2,"Subcta"},;
                {"1020-0001-0001-0000", 3,"Subsubcta"},;
                {"1020-0001-0001-0001", 4,"subsubctanddetalles"} }                    
                   
    TREE oTree  
    nLevel:=aItems[1][2]
    nTreeCount:=0            
    For i:=1 to Len(aItems)
        if aItems[i][2] > nLevel
            TREE
            nTreeCount++
        Elseif aItems[i][2] < nLevel
            nPrevLevel:=nLevel
            nCurLevel:=aItems[i][2]
            nLevelDiff:=nPrevLevel-nCurLevel
            For j:=1 to nLevelDiff
                ENDTREE
                nTreeCount--
            Next
        Endif    
        TREEITEM aItems[i][3] CARGO { aItems[i][1] }  // Item Code
        nLevel:=aItems[i][2]
    Next              
    if nTreeCount > 0
       For i:=nTreeCount To 1 Step -1
          ENDTREE
       Next
    Endif        
    ENDTREE
Return oTree

Regards
Anser
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Xbrowse Tree using Array instead of DBF

Postby ACC69 » Thu Jul 26, 2012 4:02 pm

anserkk wrote:To do a test with your FWH ver, I don't have FWH 8.12 here with me right now.

Many changes has been implemented to Tree after Ver 8.12

Anyway Tree with your data is working fine here with the latest FWH version.

CUENTAS NIVEL DESCRIPCION
1020-0000-0000-0000 1 Cuenta mayor
1020-0001-0000-0000 2 Subcta
1020-0001-0001-0000 3 Subsubcta
1020-0001-0001-0001 4 subsubctanddetalles

Image

Code: Select all  Expand view  RUN
#include "FiveWin.ch"
#include "xBrowse.ch"
//---------------------//
Function Main()

    Local oBrw,oWnd
   
    DEFINE WINDOW oWnd TITLE "Tree using Array"
    @0,0 XBROWSE oBrw OF oWnd
   
    WITH OBJECT oBrw
      :SetTree(BuildTree())
      :oTree:OpenAll()
      :CreateFromCode()
    END
   
    oWnd:oClient:=oBrw
    ACTIVATE WINDOW oWnd
Return NIL

//---------------------//
Function BuildTree()

    Local oTree,nTreeCount,nPrevLevel,nCurLevel,nLevelDiff
    Local i,j
/*    Local aItems:={ {"01","Computers"      ,0},;
                    {"02","Core i3"        ,1},;
                    {"03","Core i5"        ,1},;  
                    {"04","Furnitures"     ,0},;
                    {"05","Tables"         ,1},;  
                    {"06","Computer Table" ,2},;
                    {"07","Regular Table"  ,2},;                    
                    {"08","Desk"           ,1},;
                    {"09","Computer Desk"  ,2},;                    
                    {"10","Regular Desk"   ,2},;                    
                    {"11","Chairs"         ,1} }  
*/
                   
Local aItems:={ {"1020-0000-0000-0000", 1,"Cuenta mayor"},;
                {"1020-0001-0000-0000", 2,"Subcta"},;
                {"1020-0001-0001-0000", 3,"Subsubcta"},;
                {"1020-0001-0001-0001", 4,"subsubctanddetalles"} }                    
                   
    TREE oTree  
    nLevel:=aItems[1][2]
    nTreeCount:=0            
    For i:=1 to Len(aItems)
        if aItems[i][2] > nLevel
            TREE
            nTreeCount++
        Elseif aItems[i][2] < nLevel
            nPrevLevel:=nLevel
            nCurLevel:=aItems[i][2]
            nLevelDiff:=nPrevLevel-nCurLevel
            For j:=1 to nLevelDiff
                ENDTREE
                nTreeCount--
            Next
        Endif    
        TREEITEM aItems[i][3] CARGO { aItems[i][1] }  // Item Code
        nLevel:=aItems[i][2]
    Next              
    if nTreeCount > 0
       For i:=nTreeCount To 1 Step -1
          ENDTREE
       Next
    Endif        
    ENDTREE
Return oTree

Regards
Anser



Gracias Anserk, yo creo que si tienes razon, ha de ser mi version, porque hasta la variable nLevel, la tuve que definir ,porque no me la reconocia,le preguntare a Antonio LInares, con cual podria sustituir la variable aItems, para mi version 8.12., o hay otra manera de crear para ese modulo que me esta dando vueltas la cabeza, con mi arbol de catalogo de cuentas.

Gracias de todos modos y un saludos

Atte: Adrian C. C.
ACC69
 
Posts: 632
Joined: Tue Dec 12, 2006 7:34 pm

Re: Xbrowse Tree using Array instead of DBF

Postby Eoeo » Thu Jul 26, 2012 5:23 pm

and if I wish insert a check for each item how I can make ?

for a sample I have a menu items and I wish show any items instead of others
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm

Re: Xbrowse Tree using Array instead of DBF

Postby Otto » Thu Jul 26, 2012 5:39 pm

Silvio,
try to use oBrw:bIndent.

Best regards,
Otto
Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6364
Joined: Fri Oct 07, 2005 7:07 pm

Re: Xbrowse Tree using Array instead of DBF

Postby Eoeo » Thu Jul 26, 2012 8:05 pm

where ? can you modify the test made from Anserkk please ?
or made another

I use an array to create ribbon

aMenuRibbon := { "Gestione Ufficio Tecnico","Hardware","Software","Manuali","Prestiti","Magazzino","Utilità","Aiuto" }
::obar:=TRibbonBar():New(::oWndMain, aMenuRibbon,,,,140,25,,,,,,,,,,.F.,1 )

we can create a configuration to set wich menu we not want to show....
User avatar
Eoeo
 
Posts: 222
Joined: Mon Jun 04, 2012 12:00 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 74 guests