- Home
- Categorie
- Coding e Sistemistica
- Coding
- Treeview - Albero
- 
							
							
							
							
							
Treeview - AlberoSalve, 
 volevo sapere come fosse possibile realizzare (se avete qualche link, spezzone di codice...) il classico menù ad albero tenendo presente che le categorie e le sottocategorie sono prese dal database e che a sinistra della scritta sia presente il classico quadratino con il + se il menù è espandibile e - se non lo è.|+| Categoria 
 ---|+| Sottocategoria
 -------|-| Prodotto 1Grazie  
 
- 
							
							
							
							
							
L'albero che fa al caso mio può essere così: wwwPUNTOdestroydropPUNTOcom/javascripts/tree/default.html 
 Solo che le categorie e le sottocategorie non devono essere statiche ma popolate da un database, quindi pensavo ad un ciclo WHILE mysql_fetch_array.Come posso renderlo dinamico??? [HTML]<script type="text/javascript"> <!-- d = new dTree('d'); d.add(0,-1,'My example tree'); d.add(1,0,'Node 1','example01.html'); d.add(2,0,'Node 2','example01.html'); d.add(3,1,'Node 1.1','example01.html'); d.add(4,0,'Node 3','example01.html'); d.add(5,3,'Node 1.1.1','example01.html'); d.add(6,5,'Node 1.1.1.1','example01.html'); d.add(7,0,'Node 4','example01.html'); d.add(8,1,'Node 1.2','example01.html'); d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif'); d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir'); d.add(11,9,'Mom\'s birthday','example01.html'); d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif'); document.write(d); //--> </script>[/HTML]
 
- 
							
							
							
							
							
Lo schema è questo: |+| Categoria 1 
 ---|+| SottoCategoria A
 ----|-|Prodotto AA1
 ----|-|Prodotto AA2
 ----|-|Prodotto AA3
 ---|+| SottoCategoria B
 ----|-|Prodotto BB1
 ----|-|Prodotto BB2
 ----|-|Prodotto BB3|+| Categoria 2 
 ---|+| SottoCategoria C
 ----|-|Prodotto CC1
 ----|-|Prodotto CC2
 ----|-|Prodotto CC3
 ---|+| SottoCategoria D
 ----|-|Prodotto DD1
 ----|-|Prodotto DD2
 ----|-|Prodotto DD3La tabella Categoria sarà intuitivamente composta così: 
 id_cat
 nome_cat (es. Condomini)La tabella Sottocategoria: 
 id_scat
 id_cat
 nome_scat (es. inquilini)La tabella Prodotti: 
 id_prod
 id_cat
 id_scat
 nome_prod (es. stanze della casa)Quindi ogni nodo non sarà preimpostato ma dovrà essere generato dal database!