Dec 07, 2011, 7:46 AM
TreePanel and child
hi,
i've a database with some fields (key, father, title, ecc...). i need to put them in a treepanel searching foreach parentnode child.
I hope that I was well expressed, and sorry for my bad english ^^
i've a database with some fields (key, father, title, ecc...). i need to put them in a treepanel searching foreach parentnode child.
[...]
myRows = dt.Select();
for (int p = 0; p < myRows.Length; p++)
{
Ext.Net.TreeNode parentNode;
if (myRows[p]["FATHER"].ToString() == "")
{
// Create Parent Node if field "FATHER" is null
parentNode = new Ext.Net.TreeNode();
parentNode.Text = myRows[p]["TITLE"].ToString();
parentNode.Icon = Ext.Net.Icon.Application;
parentNode.NodeID = myRows[p]["KEY"].ToString();
root.Nodes.Add(parentNode);
}
else
{
foreach (Ext.Net.TreeNode nodo in root.Nodes.) // create childnodeID
{
if (nodo.NodeID == myRows[p]["FATHER"].ToString())
{
//Ext.Net.TreeNode nodo = root.Nodes[0];
Ext.Net.TreeNode childNode = new Ext.Net.TreeNode();
childNode.Text = myRows[p]["TITLE"].ToString();
childNode.NodeID = myRows[p]["KEY"].ToString();
nodo.Nodes.Add(childNode);
}
}
This code works, but i need to populate tree in each level of child, with a recursive method, or something like that.I hope that I was well expressed, and sorry for my bad english ^^