Page 1 of 1

como se la cantidad de items que tiene un tree?

PostPosted: Sat Oct 25, 2008 1:33 am
by goosfancito
Hola.
Como se la cantidad de items que posee un Tree, no las ramas sino el total de items que tiene en todas las ramas.

Gracias.

PostPosted: Sat Oct 25, 2008 9:43 am
by Antonio Linares
Gustavo,

Len( oTreeView:aItems )

PostPosted: Sat Oct 25, 2008 10:23 am
by goosfancito
Antonio,
Si hago eso, me devuelve la cantidad de "padres" que tiene el arbol. pero no los hijos, yo necesito conocer la cantidad de hijos. si no existe lo hago de otra forma.

Gracias.
Antonio Linares wrote:Gustavo,

Len( oTreeView:aItems )

PostPosted: Sat Oct 25, 2008 10:29 am
by Antonio Linares
Prueba esta función:
Code: Select all  Expand view
function TreeViewItems( oTreeView )

   local oItem, n, nItems := 0

   for n := 1 to Len( oTreeView:aItems )
       oItem = aItems[ n ]
       nItems++
       if Len( oItem:aItems ) != 0
          nItems += TreeViewItems( oItem )
       endif
   next

return nItems

PostPosted: Sat Oct 25, 2008 10:34 am
by goosfancito
Amigo,

Justo eso estube haciendo pero pense que habia una forma directa.

GRacias.

Antonio Linares wrote:Prueba esta función:

Code: Select all  Expand view
function TreeViewItems( oTreeView )

   local oItem, n, nItems := 0

   for n := 1 to Len( oTreeView:aItems )
       oItem = aItems[ n ]
       nItems++
       if Len( oItem:aItems ) != 0
          nItems += TreeViewItems( oItem )
       endif
   next

return nItems