Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TreeView Collapse and Expand All#8324

Unanswered
digitaldirk asked this question inQ&A
Discussion options

Hi,

Is there a way to programmatically collapse and expand all treeview items?

Thank you

You must be logged in to vote

Replies: 1 comment

Comment options

Here is how I programmatically collapse and expand all treeview items, but I hope someone can explain what I might be doing wrong that requires the Task.Delay to make everything work. Here is a link to demo the issue.
https://try.mudblazor.com/snippet/cEwpbvlYKblgteLw

private async Task CollapseAllNodes(){    await _treeView.CollapseAllAsync();}private async Task RadioButtonChanged(int rbValue){    Console.WriteLine($"Radio button changed to: {rbValue}");    await CollapseAllNodes();    // 11/9/2025 Delay fixes bug where ExpandToLevel fails    await Task.Delay(500);   //    <--- WHY IS THIS NECESSARY????    ExpandToLevel(TreeItems,0, rbValue);}private void ExpandToLevel(List<TreeItemData<ICD10DiagCode>> items, int currentLevel, int targetLevel){    if (items == null || currentLevel >= targetLevel)    {        return;    }    foreach (var item in items)    {        //_expandedItems.Add(item); // Add the current item to expanded        item.Expanded = true;        if (item.Children != null && item.Children.Any())        {            ExpandToLevel(item.Children, currentLevel + 1, targetLevel);        }    }}
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@digitaldirk@kensmith38

[8]ページ先頭

©2009-2025 Movatter.jp