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

NodeAdding and NodeAdded never triggered

3 Answers 64 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 24 Feb 2012, 05:26 PM
Hi,
I have a treeview set like this in Q1 2012:
            treeViewProjets.DataSource = ViewModel.Projets;
            treeViewProjets.DisplayMember = @"Nom\Nom";
            treeViewProjets.ValueMember = @"Id\Id";
            treeViewProjets.ChildMember = @"Projets\ObjetsProjet";
            treeViewProjets.NodeAdded += new RadTreeView.RadTreeViewEventHandler(treeViewProjets_NodeAdded);
            treeViewProjets.NodeAdding += new RadTreeView.RadTreeViewCancelEventHandler(treeViewProjets_NodeAdding);
            treeViewProjets.NodeFormatting += new TreeNodeFormattingEventHandler(treeViewProjets_NodeFormatting);

I get a root node and many child nodes created, but the events NodeAdded and NodeAdding are never triggered, NodeFormatting triggers fine.

Any idea?

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 29 Feb 2012, 12:18 PM
Hi Christian,

The NodesAdding, NodesAdded are fired when a new RadTreeNode is added to the RadTreeNodeCollection. These events are not raised when the binding is set up or when the whole data is reset. 

If you continue to experience the issue, please give us a more detailed description of your scenario and some code snippets to provide you with further assistance.
 
Kind regards,
Julian Benkov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Christian
Top achievements
Rank 1
answered on 05 Mar 2012, 06:04 PM
So is there an event triggered for added nodes when using a datasource?  I want to set the checked state based on a property on the databound item.  Basically this:

void treeViewProjets_NodeAdded(object sender, RadTreeViewEventArgs e)
{
    var sondage = e.Node.DataBoundItem as Sondage;
    e.Node.Checked = sondage.IsVisible;
}

What would be the way to set the initial checked state using databinding?
0
Julian Benkov
Telerik team
answered on 08 Mar 2012, 02:34 PM
Hi Christian,

Currently, we not support this functionality for bound mode. I logged this feature request in our Public Issue Tracking System. We will implement ItemDataBound event for this scenario. Currently, you can use and move your code in NodeFormatting event:

void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
{
    var sondage = e.Node.DataBoundItem as Sondage;
    e.Node.Checked = sondage.IsVisible;
}

I hope this helps.

Thank you for you time and cooperation. Your Telerik points have been updated.

Regards,
Julian Benkov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Treeview
Asked by
Christian
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Christian
Top achievements
Rank 1
Share this question
or