[CLOSED] Adding childNode to parentNode problem

  1. #1

    [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;

    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]
  2. #2
    Hi @metci,

    Please clarify do you run this code during initial Page_Load or DirectEvent/DirectMethod?
  3. #3
    Hi Daniil,

    I noticed my error eventually, succeeded to run. It runs on PageLoad.

    It looks like my approach is correct.

    But leafs is like expandable,actually it shouldn't be.Because I couldn't set True property to the leafs as Node.Leaf=True.To overcome this,what do you suggest me?

    Like following

    Click image for larger version. 

Name:	treepanel.png 
Views:	86 
Size:	10.1 KB 
ID:	24303
  4. #4
    It runs on PageLoad.
    Then I would recommend you to try getting rid of .AppendChild() calls. You would increase performance significantly if populate a Root's Children and so on. Here is an example:
    https://examples3.ext.net/#/TreePane...sh_Static_Tree

    But leafs is like expandable,actually it shouldn't be.Because I couldn't set True property to the leafs as Node.Leaf=True.To overcome this,what do you suggest me?
    Please set
    node.Leaf = true;

Similar Threads

  1. How TreePanel with MenuItem for add childnode.
    By vnmacedo in forum 2.x Help
    Replies: 0
    Last Post: Feb 13, 2013, 6:02 PM
  2. how to add childnode of columntree
    By xcyapcc in forum 1.x Help
    Replies: 0
    Last Post: Jul 02, 2011, 7:41 AM
  3. Closing a tab causes dom parentNode is null error
    By logicspeak in forum 1.x Help
    Replies: 5
    Last Post: Aug 20, 2010, 5:19 PM
  4. [CLOSED] [1.0] parentNode is null error
    By tansu in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 18, 2010, 2:16 PM
  5. How to get parentnode id in a tree control?
    By Kamal in forum 1.x Help
    Replies: 4
    Last Post: Jul 24, 2009, 9:06 PM

Tags for this Thread

Posting Permissions