Declined
Last Updated: 04 Sep 2024 14:30 by ADMIN
Matthijs
Created on: 27 Aug 2024 08:59
Category: TreeView
Type: Bug Report
1
In treeview, when selecting all children the parent is not checked

Steps to reproduce:

  1. Open this edited Telerik REPL link, the original link came from TreeView - CheckBoxes, and I only changed "CheckedItems = Data.Skip(1).Take(2)" to "CheckedItems = Data.Skip(1).Take(4)".
  2. Run

Expected: Both the parent "Documents" and its 4 children should be checked.

Actual: Only the 4 children are checked; the parent remains unchecked.

This only happens when all children are checked. However, if not all children items are checked, the parent will also be checked.

4 comments
Matthijs
Posted on: 04 Sep 2024 12:42
Thank you for your explanation, it makes sense.
ADMIN
Hristian Stefanov
Posted on: 02 Sep 2024 15:01

Hi Matthijs,

Thank you for getting back to me with more information on your situation. Let me shed some more light on the matter below.

CheckParents="@true" and CheckChildren="@true" define how the TreeView reacts to user behavior. When checking and unchecking items programmatically, you need to handle all parents and children explicitly.

The indeterminate state is only a visual indication for the user. Indeterminate items are not present in @bind-CheckedItems="@SelectedItems".

There are two reasons why we don't check and uncheck items automatically during programmatic operations:

  • In this way we give full control and more flexibility to the app and the developer. If we managed the checked items automatically in this case, this may be limiting to you.
  • It is a general best practice for UI components not to interfere or override programmatic operations on them.

Regards,
Hristian Stefanov
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.

Matthijs
Posted on: 27 Aug 2024 12:03

Hi Hristian,

 

Thanks for your response.

 

This was just an example, in our use case we don't know which of the children were checked. For example, if 3 out of 4 were checked we do see this: (I changed the line to: CheckedItems = Data.Skip(2).Take(3).ToList();)

So documents is now in an "indeterminate state". This is expected, but when all 4 children are selected, the parent should be selected too which isn't the case:

ADMIN
Hristian Stefanov
Posted on: 27 Aug 2024 11:25

Hi Matthijs,

I’m curious about why you’d want the parent node to be checked on initialization when it was explicitly skipped in the OnInitialized handler. Given that the code is intentionally set to skip that parent, this behavior seems to align with the expected result from this implementation.

I’d appreciate your feedback on this perspective.

Regards,
Hristian Stefanov
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024