Oct 27, 2015, 6:42 AM
[CLOSED] Adding childNode to parentNode problem
hi,
I am new to ext.net. I have a department table which has records with department-child department relaton in an Oracle DB. I got the records by using "connect by prior". I am planning to load tree foreach loop like following;
Is my approach above wrong ?
Thanks in advance,
I am new to ext.net. I have a department table which has records with department-child department relaton in an Oracle DB. I got the records by using "connect by prior". I am planning to load tree foreach loop like following;
foreach (var obj in l)
{
if (obj.DepartmentParentOid == null || obj.DepartmentParentOid == 0)
{
Ext.Net.Node root = new Ext.Net.Node();
root.NodeID = obj.Oid.ToString();
root.Text = obj.DepartmentName;
root.Expanded = true;
TreePanel1.Root.Add(root);
}
else
{
Ext.Net.NodeProxy np = TreePanel1.GetStore().GetNodeById(obj.DepartmentParentOid);
Ext.Net.Node child = new Node();
child.NodeID = obj.Oid.ToString();
child.Text = obj.DepartmentName;
np.AppendChild(child);
}
}
But it gave me the exception:NullreferenceExeption was unhandled by user code"
Because my store is null, but I set the root node before.I couldn't find store is null.Is my approach above wrong ?
Thanks in advance,
Last edited by Daniil; Nov 10, 2015 at 11:59 AM.
Reason: [CLOSED]