1

As mentioned in the subject line I wanted to know why the MudBlazor Tree View display the edit view on the 1st click but all subsequent clicks only change the URL & does not update the view. Please find the code snippet to the .razor file as well as the code behind.

Razor file snippet:

<MudTreeView Hover T="ClientTreeItem" ReadOnly Color="Color.Tertiary">

    <MudTreeViewItem Text="Client List" Expanded="true">
        @foreach (var client in Model)
        {
            <div @onclick="@(OpenContextMenu)" @oncontextmenu="@(OpenContextMenu)" @oncontextmenu:preventDefault @oncontextmenu:stopPropagation>
                <MudTreeViewItem T="ClientTreeItem" Value="@CreateClientItem(client)" OnClick="@((e) => OnClientClick(client))" Text="@client.ClientName" Icon="@Icons.Material.Filled.Business" Expanded="false">
                ....
            </div>
        }
    </MudTreeViewItem>
</MudTreeView>

Code behind file snippet:

private void OnClientClick(ClientNavigationContextDto client)
{
    // Check if the client exists
    if (client == null)
        return;

    EditClient(client.ClientId);
}

private void EditClient(int clientId)
{
    // Navigate to edit page by ID
    NavigationManager.NavigateTo($"/clients/{clientId}");
}

Output:

The on click of the client displays the edit view as expected!

![enter image description here

All subsequent clicks on the client Tree view item update the URL but not the view as seen below.

![enter image description here

2
  • @jsotola apologize I'll update my post accordingly, however it seems like I need to add a onparameterset method so that when I click on another client the view gets updated! Commented Oct 31 at 7:48
  • please do not apologize ... no need to write a comment Commented Oct 31 at 14:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.