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

Cascading checkbox nodes - how do I know when cascading is all done?

1 Answer 92 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 20 Jan 2017, 09:01 PM

Hi,

I am using a TreeView with checkboxes enabled and TriState enabled. If I click on a parent node checkbox it affects the checkbox state of its children, and vice versa. I would like to be able to save the tree state whenever the tree checkboxes are changed by a user, but only when ALL of the cascading is finished.

How can I do that?

Note: I tried to use the TreeView1.NodeCheckedChanged event - but this event fires for EVERY checkbox change. I only want to run my code once, at the very end.

Thanks,

-Lou

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 23 Jan 2017, 04:38 PM
Hi Lou,

Thank you for writing.

The check state for each of the nodes is evaluated raising the NodeCheckedChanging and NodeCheckedChanged events. However, there is no notification when this update finishes.

Achieving your task is possible and for the purpose, you can handle the MouseUp event of the tree. By the time the event fires all of the nodes will have been updated. In the event handler you can perform a check for the clicked element and then iterate the tree: 
public Form1()
{
    InitializeComponent();
 
    this.radTreeView1.MouseUp += radTreeView1_MouseUp;
}
 
private void radTreeView1_MouseUp(object sender, MouseEventArgs e)
{
    RadTreeView tree = (RadTreeView)sender;
    TreeNodeCheckBoxElement checkBox = tree.ElementTree.GetElementAtPoint(e.Location) as TreeNodeCheckBoxElement;
    if (checkBox != null)
    {
        //Save state.
    }
}

I hope this helps. Please let me know if you need further assistance.

Regards,
Hristo
Telerik by Progress
Try our brand new, jQuery-free Angular 2 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
Lou
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or