Get list of partially checked items from treeview???

1 Answer 27 Views
TreeView
Ed
Top achievements
Rank 1
Iron
Veteran
Iron
Ed asked on 11 Apr 2022, 02:00 PM

Hi,

I have a need to be able to get partially checked root items. Basically, I want to tell by looking a given child node, who it's root parent is.

Is there a way I can tell which are partially checked?

Thanks ... Ed

 

1 Answer, 1 is accepted

Sort by
0
Nadezhda Tacheva
Telerik team
answered on 14 Apr 2022, 08:07 AM

Hi Ed,

The current behavior of the TreeView CheckBox selection if CheckParents is enabled is to mark the parents in indeterminate state when some (not all) of their children are selected. If all the children are checked, the parent will be checked, too. You may test that behavior in the live demo.

As far as I can understand, you want to get a list of the parents that are in indeterminate state (partially checked). To do that, you should loop through the data collection and find the parents of the checked items. You may handle the CheckedItemsChanged event of the TreeView to perform that operation. To get only the partially checked items, you should also check if all their children are checked since in this case the parent will also be checked (not partially). It will be easier to achieve the result if you work with flat data collection as you can look for parent id match.

I hope you will find the above information useful. Please let us know if any further questions appear.

Regards,
Nadezhda Tacheva
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ed
Top achievements
Rank 1
Iron
Veteran
Iron
commented on 14 Apr 2022, 08:40 AM

Understood. I was just trying to be lazy and see if someone had already written that kind of code.

Thanks.

Just remember, that in order to understand recursion, you must first understand recursion.

 

Tags
TreeView
Asked by
Ed
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Nadezhda Tacheva
Telerik team
Share this question
or