public partial class DepartmentsDto
{
public int DepNo { get; set; }
public string DepDepid { get; set; } = null!;
public int DepParentid { get; set; }
public string DepName { get; set; } = null!;
public List<DepartmentsDto> Children { get; set; } = [];
}
This is a tree structure data with an indefinite depth. When I use this component, I find that when the parent node is not expanded, it will not make any check or selection judgments on the child nodes. It seems to be a lazy loading mechanism, but it goes against the user's operation logic, as shown in the video. Is there any parameter to adjust this aspect so that the check status of the child node can operate normally even without expanding the parent node?
I have tested this method, but its rendering still requires the parent node to be expanded before its value can be obtained through args.
However, I also wrote my own CheckedValuesChanged method, but the execution order is to execute ItemRender first, then CheckedValuesChanged, which will cause ItemRender to use the data before checking, resulting in the inability to meet the requirements.
Got it, sorry, thank you for your patient reply.
I was thinking that there might be something wrong with the logic in ItemRender, which led to it not working as I wanted. I will rewrite the logic to see if it can meet my needs.
Thank you very much for your help, and I'm sorry that it took you some time to deal with my problem.
Figure4. Expected results
But the UI you see in the user experience should be displayed regardless of whether the parent node is expanded...
When all child nodes are selected, the parent node will be checked (true)
When the child node is partially selected, the parent node will display null
When all child nodes are not selected, the parent node will be displayed as unchecked (false)
Because the current TreeItemRender method seems to obtain the properties and values of child nodes only when the parent node is expanded, but in practice, sometimes there is no need to expand the parent node. Simply checking the parent node can add the values of all child nodes to CheckedValue.
That's why I have more doubts about this. Please forgive me and thank you for your patient help.
I'll try to explain again. The parent node cannot know if there are checked/unchecked children unless they are expanded - before the expansion no children exist. To set the parent node checked state you should use a logic independent of children expansion in ItemRender:
Got it, sorry, thank you for your explanation!
I understand how to use this component, and I try to write logic through component methods to make this logic work as I want.
I'm really sorry to have you spend so much time explaining. Thank you for your help!