This is a migrated thread and some comments may be shown as answers.

RadTreeNode.Treeview Does not Return the Treeview

5 Answers 10 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Holger
Top achievements
Rank 1
Holger asked on 20 May 2018, 10:00 AM

If I handle a RadTreeNode in this way:

public partial class RadForm2 : Telerik.WinControls.UI.RadForm
    {
        private RadTreeNode m_myNode1;
        private RadTreeNode m_myNode2;
        public RadForm2()
        {
            InitializeComponent();
 
            m_myNode1 = new RadTreeNode();
            m_myNode2 = new RadTreeNode();
 
            m_myNode1.Nodes.Add(m_myNode2);
 
            radTreeView1.Nodes.Add(m_myNode1);
        }
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            var treeview1 = m_myNode1.TreeView;
            if (treeview1 == null)
                throw new InvalidOperationException();
 
            //var x = m_myNode2.TreeViewElement; this solves the problem, by calling FindTreeView internally
            var treeview2 = m_myNode2.TreeView;
            if (treeview2 == null)
                throw new InvalidOperationException();
        }
    }

 

The second Exception is thrown.

The workaround is in the comment, if you call m_myNode2.TreeViewElement or m_myNode2.Nodes before, everything works fine,

anything that causes internally a call to "TreeViewElement" or "FindTreeView" (i digged a bit in the source code).

So this happens only on Nodes, without Childnodes and not for Rootnodes.

It's more a Bug-Report than a Question, but don't know where to Post ist.

If  the TreeView Property is the first Property called, on a RadTreeNode, it always has the value null.

 

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 May 2018, 08:54 AM
Hello, Holger,    

Indeed, the TreeView property of the inner RadTreeNodes is initially loaded only for the top level nodes. The inner nodes use the TreeViewElement to load lazy the Treeview property. This is how the RadTreeView is internally implemented. Feel free to use the TreeViewElement property. It give you access to the common properties of the tree view functionality.

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Holger
Top achievements
Rank 1
answered on 22 May 2018, 09:21 AM

Your answer does not seem to confirm, that this is a bug.

 

RadTreeNode.Treeview does not return the associated TreeView, even if attached to a treeview.

"Lazy Loading" meens, it is called, when you access it. But it's not called.

 

If you offer a Property "TreeView" with the Documentation "returns the Treeview, the node is attached to",

it should work always and not just under some condition. It feels like playing Roulette with the return value of this property.

Sometimes it returns the Treeview, sometimes it doesn't.

 

Using TreeViewElement ist just a workaround, because this TreeView property is not working as documented.

 

 

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 May 2018, 10:14 AM
Hello, Holger,    

If this seems confusing for you, we will log an item in our feedback portal in order to investigate the precise case and see how it can be improved. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points

I hope this information helps. If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Holger
Top achievements
Rank 1
answered on 22 May 2018, 11:42 AM

OK, thank you. Seems to be the right place for the subject.

The source-code seems to be modified recently, there are a few out-commented lines in this area.

And adding this little call FindTreeView() in the getter of the Treeview property should be easy.

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 May 2018, 10:45 AM
Hello, Holger,    

We will investigate the recent changes when addressing this issue and a proper fix will be introduced accordingly. Feel free to follow the feedback item in order to get notified as soon as some changes occur.

If you have any additional questions, please let me know. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Treeview
Asked by
Holger
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Holger
Top achievements
Rank 1
Share this question
or