Hello,
im trying to render a treview but its not showing any item, im also print the results of my query on a table using a for loop and it shows the results ok , but the trevieww its not loading any data. Attached my code :
@inherits LayoutComponentBase
@inject Blazored.LocalStorage.ILocalStorageService oLocalStorage
@using MAPCRUD.Model
@using MAP.Interfaces
@inject IMapTreeviewMenuService MapTreeviewMenuService
<TelerikRootComponent>
<div class="sidebar">
<NavMenu />
@if (MapMenuData == null)
{
<p><em>Loading...</em></p>
}
else
{
<TelerikTreeView Data="@MapMenuData">
<TreeViewBindings>
<TreeViewBinding ParentIdField="@(nameof(MapTreeviewMenu.ParentIdValue))" TextField="@(nameof(MapTreeviewMenu.Text))" UrlField="@(nameof(MapTreeviewMenu.Url))" IconField="@(nameof(MapTreeviewMenu.Icon))" ></TreeViewBinding>
</TreeViewBindings>
</TelerikTreeView>
<table>
<thead>
<tr>
<th>Text</th>
</tr>
</thead>
<tbody>
@foreach (var menuData in MapMenuData)
{
<tr>
<td style="color:#fff;">@menuData.Url</td>
</tr>
}
</tbody>
</table>
}
</div>
<div class="main">
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
</div>
<div class="content px-4">
@Body
</div>
</div>
</TelerikRootComponent>
@code {
private IEnumerable<MapTreeviewMenu> MapMenuData;
protected override async Task OnInitializedAsync()
{
await oLocalStorage.SetItemAsync("CollegeID", 1);
await oLocalStorage.SetItemAsync("ApplicationID", 1);
await oLocalStorage.SetItemAsync("RoleID", 2);
await oLocalStorage.SetItemAsync("UserID", 1);
int CollegeID = await oLocalStorage.GetItemAsync<int>("CollegeID");
int ApplicationID = await oLocalStorage.GetItemAsync<int>("ApplicationID");
int RoleID = await oLocalStorage.GetItemAsync<int>("RoleID");
int UserID = await oLocalStorage.GetItemAsync<int>("UserID");
MapMenuData = await MapTreeviewMenuService.GetMenuItems(CollegeID, ApplicationID, RoleID, UserID);
}
}