Tree Drag And Drop issue #1561

Closed
opened 2026-01-29 17:55:26 +00:00 by claunia · 2 comments
Owner

Originally created by @Jhonan01 on GitHub (Jan 3, 2025).

I'm facing this error on my page "System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenTreeItem' has the same key value, 'Dara2.Components.POI'. Key values must be unique."

Below print my screen. I'm using .net8.0 and threejs

image

Below the Index.razor

@page "/PlantPOIs"
@using Microsoft.EntityFrameworkCore
@using Microsoft.AspNetCore.Components.QuickGrid
@using Dara2.Components
@using Dara2.Data
@implements IAsyncDisposable
@inject IDbContextFactory<Dara2.Data.Dara2Context> DbFactory

@rendermode InteractiveServer
@using HomagGroup.Blazor3D.Extras.Core;

@using Radzen
@using System.Linq
@using Radzen.Blazor

Dara2

Scene

    <!-- Div para a lista de objetos -->
    <div class="col-4 objects-list">
        <h4>Menu</h4>

        <!-- Aba de navegação -->
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link @GetTabClass(1)" @onclick="() => ActivateTab(1)">Scene</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @GetTabClass(2)" @onclick="() => ActivateTab(2)">Tab 2</a>
            </li>
            <li class="nav-item">
                <a class="nav-link @GetTabClass(3)" @onclick="() => ActivateTab(3)">Tab 3</a>
            </li>
        </ul>

        <!-- Conteúdo das abas -->
        <div class="tab-content mt-3">
            <div class="tab-pane @GetTabContentClass(1)" id="tab1">
                <h5>List of Objects</h5>
                <ul>
                    <!-- RadzenTree Component para arranjar POIs com drag and drop -->
                    <RadzenTree Data="@hierarchicalPois" Style="height: 300px" ItemRender="ItemRender">
                        <RadzenTreeLevel TextProperty="Name" ChildrenProperty="Children"
                                         Expanded="@(i => true)"
                                         HasChildren="@(i => ((POI)i).Children?.Any() == true)" />
                    </RadzenTree>
                </ul>
            </div>

            <div class="tab-pane @GetTabContentClass(2)" id="tab2">
                <p>This is the content for <b>Tab 2</b>.</p>
            </div>
            <div class="tab-pane @GetTabContentClass(3)" id="tab3">
                <p>This is the content for <b>Tab 3</b>.</p>
            </div>
        </div>
    </div>
</div>

Create New

<TemplateColumn Context="poi">
    <a href="@($"PlantPOIs/edit?id={poi.Id}")">Edit</a> |
    <a href="@($"PlantPOIs/details?id={poi.Id}")">Details</a> |
    <a href="@($"PlantPOIs/delete?id={poi.Id}")">Delete</a>
</TemplateColumn>

@code {
private Viewer View3D1 = null!;
private Scene scene = new Scene();
private Guid lastSelectedGuid;
private Guid lastCubeGuid;

private ViewerSettings settings = new ViewerSettings()
    {
        CanSelect = true,
        CanSelectHelpers = false
    };

private Dara2Context context = default!;

PaginationState state = new PaginationState { ItemsPerPage = 2 };
string NameFilter = "";

private IQueryable<POI> FilterPOI => filteredPois.AsQueryable();

private int activeTab = 1;

private static List<POI> pois = new List<POI>(); // Lista para armazenar os POIs carregados
private List<POI> hierarchicalPois = new(); // POIs organizados hierarquicamente

private POI? draggedItem;

private List<POI> allPois = new();
private List<POI> filteredPois = new();

protected override void OnInitialized()
{
    context = DbFactory.CreateDbContext();
    LoadSceneFromDatabase();
}

public async ValueTask DisposeAsync() => await context.DisposeAsync();

protected override async Task OnInitializedAsync()
{
    using var localContext = DbFactory.CreateDbContext();
    allPois = await localContext.POI.ToListAsync();
    ApplyFilter(); // Atualiza os dados filtrados

    // Construir hierarquia
    BuildHierarchy();
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        View3D1.ObjectSelected += OnObjectSelected;
    }
    // Chame o carregamento da cena aqui, pois View3D1 já estará inicializado
    AddLights();
    AddGridHelper();
}

private void AddLights()
{
    scene.Add(new AmbientLight());
    scene.Add(new PointLight()
        {
            Intensity = 0.5f,
            Position = new Vector3(100, 200, 100)
        });
    scene.Add(new PointLight()
        {
            Intensity = 1f,
            Position = new Vector3(5, 5, 5)
        });
}
private async Task OnClearAllClick()
{
    await View3D1.ClearSceneAsync();
    AddLights();
    await View3D1.UpdateScene();
}

private async Task OnClearLast()
{
    if (scene.Children.Count == 0)
    {
        return;
    }
    var last = scene.Children.Last();
    await View3D1.RemoveByUuidAsync(last.Uuid);
}

private void OnObjectSelected(Object3DArgs e)
{
    lastSelectedGuid = e.UUID;
}

private void AddGridHelper()
{
    // Define o tamanho e as divisões da grade
    var size = 10;
    var divisions = 10;

    // Cria o GridHelper
    var gridHelper = new GridHelper(size, divisions);

    // Adiciona ao objeto Scene
    scene.Add(gridHelper);
}

private void ActivateTab(int tabIndex)
{
    activeTab = tabIndex;
}

private string GetTabClass(int tabIndex)
{
    return activeTab == tabIndex ? "active" : "";
}

private string GetTabContentClass(int tabIndex)
{
    return activeTab == tabIndex ? "show active" : "fade";
}

public void Dispose()
{
    View3D1.ObjectSelected -= OnObjectSelected;
}

private void BuildHierarchy()
{
    hierarchicalPois.Clear();
    var lookup = pois.ToDictionary(p => p.Id);

    foreach (var poi in pois)
    {
        if (poi.ParentId == null)
        {
            hierarchicalPois.Add(poi);
        }
        else if (lookup.TryGetValue(poi.ParentId.Value, out var parent))
        {
            parent.Children ??= new List<POI>();
            parent.Children.Add(poi);
        }
    }
}

void ItemRender(TreeItemRenderEventArgs args)
{
    var poi = (POI)args.Value;

    args.Attributes.Add("title", "Arraste para reordenar");
    args.Attributes.Add("style", "cursor: grab");
    args.Attributes.Add("draggable", "true");
    args.Attributes.Add("ondragstart", EventCallback.Factory.Create<DragEventArgs>(this, () =>
    {
        draggedItem = poi;
    }));

    args.Attributes.Add("ondragover", "event.preventDefault()");
    args.Attributes.Add("ondrop", EventCallback.Factory.Create<DragEventArgs>(this, () =>
    {
        if (draggedItem != null && draggedItem != poi &&
            draggedItem.ParentId != poi.Id && draggedItem.Id != poi.ParentId)
        {
            UpdateParentRelationshipAsync(draggedItem, poi);
        }
    }));
}

private async Task UpdateParentRelationshipAsync(POI draggedItem, POI poi)
{
    using var localContext = DbFactory.CreateDbContext();
    var existingItem = await localContext.POI.FindAsync(draggedItem.Id);
    if (existingItem != null)
    {
        existingItem.ParentId = poi.Id;
        await localContext.SaveChangesAsync();
    }

    draggedItem.ParentId = poi.Id;
    BuildHierarchy();
    draggedItem = null;
    StateHasChanged();
}

private void LoadSceneFromDatabase()
{
    var DBpois = context.POI.ToList();
    pois = DBpois;

    scene.Children.Clear();
    foreach (var poi in DBpois)
    {
        var mesh = new Mesh
            {
                Geometry = new BoxGeometry(),
                Position = new Vector3((float)poi.X!, (float)poi.Y!, (float)poi.Z!),
                Name = poi.Name!
            };
        scene.Add(mesh);
    }

    View3D1?.UpdateScene();
}

private void ApplyFilter()
{
    filteredPois = allPois
        .Where(m => m.Name!.Contains(NameFilter, StringComparison.OrdinalIgnoreCase))
        .ToList();
}

private void OnFilterChanged(ChangeEventArgs e)
{
    NameFilter = e.Value?.ToString() ?? string.Empty;
    StateHasChanged(); // Re-render the grid with the filtered data
}

}

Below the POI.cs

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Dara2.Components
{
public class POI
{
public Guid Id { get; set; } // Identificador único
public string? Name { get; set; } // Nome do objeto
public string? Description { get; set; } // Descrição do objeto
public double X { get; set; } // Coordenada X
public double Y { get; set; } // Coordenada Y
public double Z { get; set; } // Coordenada Z
public Guid? ParentId { get; set; } // Identificador do pai na hierarquia

    [NotMapped] // Não salva no banco de dados
    public List<POI> Children { get; set; } = new();

}

}

Below the whole error

blazor.web.js:1 [2025-01-03T12:45:51.459Z] Error: System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenTreeItem' has the same key value, 'Dara2.Components.POI'. Key values must be unique.
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ThrowExceptionForDuplicateKey(Object key, RenderTreeFrame& frame)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.BuildKeyToInfoLookup(DiffContext diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

blazor.web.js:1 [2025-01-03T12:45:51.460Z] Information: Connection disconnected.
5
blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1
at A (blazor.web.js:1:13826)
at blazor.web.js:1:13732
at D (blazor.web.js:1:13915)
at R (blazor.web.js:1:13706)
at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308)
at P.onGlobalEvent (blazor.web.js:1:15501)
23
PlantPOIs:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
2
blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1
at A (blazor.web.js:1:13826)
at blazor.web.js:1:13732
at D (blazor.web.js:1:13915)
at R (blazor.web.js:1:13706)
at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308)
at P.onGlobalEvent (blazor.web.js:1:15501)
2
PlantPOIs:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
3
blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1
at A (blazor.web.js:1:13826)
at blazor.web.js:1:13732
at D (blazor.web.js:1:13915)
at R (blazor.web.js:1:13706)
at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308)
at P.onGlobalEvent (blazor.web.js:1:15501)

Originally created by @Jhonan01 on GitHub (Jan 3, 2025). I'm facing this error on my page "System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenTreeItem' has the same key value, 'Dara2.Components.POI'. Key values must be unique." Below print my screen. I'm using .net8.0 and threejs ![image](https://github.com/user-attachments/assets/897df284-ef47-46b8-9186-2ee9c14b82d9) Below the Index.razor @page "/PlantPOIs" @using Microsoft.EntityFrameworkCore @using Microsoft.AspNetCore.Components.QuickGrid @using Dara2.Components @using Dara2.Data @implements IAsyncDisposable @inject IDbContextFactory<Dara2.Data.Dara2Context> DbFactory @rendermode InteractiveServer @using HomagGroup.Blazor3D.Extras.Core; @using Radzen @using System.Linq @using Radzen.Blazor <PageTitle>Dara2</PageTitle> <h1>Scene</h1> <div class="custom-layout"> <div class="row"> <!-- Div para a cena 3D --> <div class="col-8 scene-container" style="height: 500px;"> <Viewer @ref="View3D1" ViewerSettings=@settings Scene=scene /> </div> <!-- Div para a lista de objetos --> <div class="col-4 objects-list"> <h4>Menu</h4> <!-- Aba de navegação --> <ul class="nav nav-tabs"> <li class="nav-item"> <a class="nav-link @GetTabClass(1)" @onclick="() => ActivateTab(1)">Scene</a> </li> <li class="nav-item"> <a class="nav-link @GetTabClass(2)" @onclick="() => ActivateTab(2)">Tab 2</a> </li> <li class="nav-item"> <a class="nav-link @GetTabClass(3)" @onclick="() => ActivateTab(3)">Tab 3</a> </li> </ul> <!-- Conteúdo das abas --> <div class="tab-content mt-3"> <div class="tab-pane @GetTabContentClass(1)" id="tab1"> <h5>List of Objects</h5> <ul> <!-- RadzenTree Component para arranjar POIs com drag and drop --> <RadzenTree Data="@hierarchicalPois" Style="height: 300px" ItemRender="ItemRender"> <RadzenTreeLevel TextProperty="Name" ChildrenProperty="Children" Expanded="@(i => true)" HasChildren="@(i => ((POI)i).Children?.Any() == true)" /> </RadzenTree> </ul> </div> <div class="tab-pane @GetTabContentClass(2)" id="tab2"> <p>This is the content for <b>Tab 2</b>.</p> </div> <div class="tab-pane @GetTabContentClass(3)" id="tab3"> <p>This is the content for <b>Tab 3</b>.</p> </div> </div> </div> </div> </div> <p> <a href="PlantPOIs/create">Create New</a> </p> <QuickGrid Class="table" Items="FilterPOI" Pagination="state"> <PropertyColumn Property="poi => poi.Name" Sortable="true"> <ColumnOptions> <div> <input type="search" value="@NameFilter" @oninput="OnFilterChanged" /> </div> </ColumnOptions> </PropertyColumn> <PropertyColumn Property="poi => poi.Description" /> <PropertyColumn Property="poi => poi.X" /> <PropertyColumn Property="poi => poi.Y" /> <PropertyColumn Property="poi => poi.Z" /> <TemplateColumn Context="poi"> <a href="@($"PlantPOIs/edit?id={poi.Id}")">Edit</a> | <a href="@($"PlantPOIs/details?id={poi.Id}")">Details</a> | <a href="@($"PlantPOIs/delete?id={poi.Id}")">Delete</a> </TemplateColumn> </QuickGrid> <Paginator State="state" /> @code { private Viewer View3D1 = null!; private Scene scene = new Scene(); private Guid lastSelectedGuid; private Guid lastCubeGuid; private ViewerSettings settings = new ViewerSettings() { CanSelect = true, CanSelectHelpers = false }; private Dara2Context context = default!; PaginationState state = new PaginationState { ItemsPerPage = 2 }; string NameFilter = ""; private IQueryable<POI> FilterPOI => filteredPois.AsQueryable(); private int activeTab = 1; private static List<POI> pois = new List<POI>(); // Lista para armazenar os POIs carregados private List<POI> hierarchicalPois = new(); // POIs organizados hierarquicamente private POI? draggedItem; private List<POI> allPois = new(); private List<POI> filteredPois = new(); protected override void OnInitialized() { context = DbFactory.CreateDbContext(); LoadSceneFromDatabase(); } public async ValueTask DisposeAsync() => await context.DisposeAsync(); protected override async Task OnInitializedAsync() { using var localContext = DbFactory.CreateDbContext(); allPois = await localContext.POI.ToListAsync(); ApplyFilter(); // Atualiza os dados filtrados // Construir hierarquia BuildHierarchy(); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { View3D1.ObjectSelected += OnObjectSelected; } // Chame o carregamento da cena aqui, pois View3D1 já estará inicializado AddLights(); AddGridHelper(); } private void AddLights() { scene.Add(new AmbientLight()); scene.Add(new PointLight() { Intensity = 0.5f, Position = new Vector3(100, 200, 100) }); scene.Add(new PointLight() { Intensity = 1f, Position = new Vector3(5, 5, 5) }); } private async Task OnClearAllClick() { await View3D1.ClearSceneAsync(); AddLights(); await View3D1.UpdateScene(); } private async Task OnClearLast() { if (scene.Children.Count == 0) { return; } var last = scene.Children.Last(); await View3D1.RemoveByUuidAsync(last.Uuid); } private void OnObjectSelected(Object3DArgs e) { lastSelectedGuid = e.UUID; } private void AddGridHelper() { // Define o tamanho e as divisões da grade var size = 10; var divisions = 10; // Cria o GridHelper var gridHelper = new GridHelper(size, divisions); // Adiciona ao objeto Scene scene.Add(gridHelper); } private void ActivateTab(int tabIndex) { activeTab = tabIndex; } private string GetTabClass(int tabIndex) { return activeTab == tabIndex ? "active" : ""; } private string GetTabContentClass(int tabIndex) { return activeTab == tabIndex ? "show active" : "fade"; } public void Dispose() { View3D1.ObjectSelected -= OnObjectSelected; } private void BuildHierarchy() { hierarchicalPois.Clear(); var lookup = pois.ToDictionary(p => p.Id); foreach (var poi in pois) { if (poi.ParentId == null) { hierarchicalPois.Add(poi); } else if (lookup.TryGetValue(poi.ParentId.Value, out var parent)) { parent.Children ??= new List<POI>(); parent.Children.Add(poi); } } } void ItemRender(TreeItemRenderEventArgs args) { var poi = (POI)args.Value; args.Attributes.Add("title", "Arraste para reordenar"); args.Attributes.Add("style", "cursor: grab"); args.Attributes.Add("draggable", "true"); args.Attributes.Add("ondragstart", EventCallback.Factory.Create<DragEventArgs>(this, () => { draggedItem = poi; })); args.Attributes.Add("ondragover", "event.preventDefault()"); args.Attributes.Add("ondrop", EventCallback.Factory.Create<DragEventArgs>(this, () => { if (draggedItem != null && draggedItem != poi && draggedItem.ParentId != poi.Id && draggedItem.Id != poi.ParentId) { UpdateParentRelationshipAsync(draggedItem, poi); } })); } private async Task UpdateParentRelationshipAsync(POI draggedItem, POI poi) { using var localContext = DbFactory.CreateDbContext(); var existingItem = await localContext.POI.FindAsync(draggedItem.Id); if (existingItem != null) { existingItem.ParentId = poi.Id; await localContext.SaveChangesAsync(); } draggedItem.ParentId = poi.Id; BuildHierarchy(); draggedItem = null; StateHasChanged(); } private void LoadSceneFromDatabase() { var DBpois = context.POI.ToList(); pois = DBpois; scene.Children.Clear(); foreach (var poi in DBpois) { var mesh = new Mesh { Geometry = new BoxGeometry(), Position = new Vector3((float)poi.X!, (float)poi.Y!, (float)poi.Z!), Name = poi.Name! }; scene.Add(mesh); } View3D1?.UpdateScene(); } private void ApplyFilter() { filteredPois = allPois .Where(m => m.Name!.Contains(NameFilter, StringComparison.OrdinalIgnoreCase)) .ToList(); } private void OnFilterChanged(ChangeEventArgs e) { NameFilter = e.Value?.ToString() ?? string.Empty; StateHasChanged(); // Re-render the grid with the filtered data } } Below the POI.cs using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Dara2.Components { public class POI { public Guid Id { get; set; } // Identificador único public string? Name { get; set; } // Nome do objeto public string? Description { get; set; } // Descrição do objeto public double X { get; set; } // Coordenada X public double Y { get; set; } // Coordenada Y public double Z { get; set; } // Coordenada Z public Guid? ParentId { get; set; } // Identificador do pai na hierarquia [NotMapped] // Não salva no banco de dados public List<POI> Children { get; set; } = new(); } } Below the whole error blazor.web.js:1 [2025-01-03T12:45:51.459Z] Error: System.InvalidOperationException: More than one sibling of component 'Radzen.Blazor.RadzenTreeItem' has the same key value, 'Dara2.Components.POI'. Key values must be unique. at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ThrowExceptionForDuplicateKey(Object key, RenderTreeFrame& frame) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.BuildKeyToInfoLookup(DiffContext diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForFramesWithSameSequence(DiffContext& diffContext, Int32 oldFrameIndex, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() blazor.web.js:1 [2025-01-03T12:45:51.460Z] Information: Connection disconnected. 5 blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1 at A (blazor.web.js:1:13826) at blazor.web.js:1:13732 at D (blazor.web.js:1:13915) at R (blazor.web.js:1:13706) at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308) at P.onGlobalEvent (blazor.web.js:1:15501) 23 PlantPOIs:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received 2 blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1 at A (blazor.web.js:1:13826) at blazor.web.js:1:13732 at D (blazor.web.js:1:13915) at R (blazor.web.js:1:13706) at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308) at P.onGlobalEvent (blazor.web.js:1:15501) 2 PlantPOIs:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received 3 blazor.web.js:1 Uncaught Error: No interop methods are registered for renderer 1 at A (blazor.web.js:1:13826) at blazor.web.js:1:13732 at D (blazor.web.js:1:13915) at R (blazor.web.js:1:13706) at P.dispatchGlobalEventToAllElements (blazor.web.js:1:16308) at P.onGlobalEvent (blazor.web.js:1:15501)
Author
Owner

@enchev commented on GitHub (Jan 4, 2025):

I'm afraid that we cannot run the code you've pasted here. Try to replicate your case using our demos (they are editable) or supply minimal reproducible and runnable example.

@enchev commented on GitHub (Jan 4, 2025): I'm afraid that we cannot run the code you've pasted here. Try to replicate your case using our demos (they are editable) or supply minimal reproducible and runnable example.
Author
Owner

@Jhonan01 commented on GitHub (Jan 7, 2025):

I solved the issue by...

private void BuildHierarchy()
{
hierarchicalPois.Clear();
var lookup = pois.ToDictionary(p => p.Id);

foreach (var poi in pois)
{
    if (poi.ParentId == null)
    {
        hierarchicalPois.Add(poi);
    }
    else if (lookup.TryGetValue(poi.ParentId.Value, out var parent))
    {
        parent.Children ??= new List<POI>();
        if (!parent.Children.Any(c => c.Id == poi.Id)) // Check if exist
        {
            parent.Children.Add(poi);
        }
    }
}

}

@Jhonan01 commented on GitHub (Jan 7, 2025): I solved the issue by... private void BuildHierarchy() { hierarchicalPois.Clear(); var lookup = pois.ToDictionary(p => p.Id); foreach (var poi in pois) { if (poi.ParentId == null) { hierarchicalPois.Add(poi); } else if (lookup.TryGetValue(poi.ParentId.Value, out var parent)) { parent.Children ??= new List<POI>(); if (!parent.Children.Any(c => c.Id == poi.Id)) // Check if exist { parent.Children.Add(poi); } } } }
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1561