RadzenDataGrid disappears in the design mode

I have this scenario: 3 tables: Users, Offices and Departments. Users table has a relationship with Departments table, but it doesn't have any relationship with Offices table. There's a stored procedure named Offices_GetAll which returns rows from Offices table.

Tables and their columns

  • Users: UserID, UserName, OfficeID, DepartmentID
  • Offices: OfficeID, OfficeName
  • Departments: DepartmentID, DepartmentName

I made CRUD pages for Users table and edited the RadzenDropDown in the AddUser and EditUser so they bind to the result of the stored procedure. I'm having trouble to bind the OfficeID in Users pages (list).

I don't know how to do it properly but this is what I did. I added a Dictionary typed field called offices, then fill it with the stored procedure result.

Snippet from Users.razor.cs

protected Dictionary<int, string> offices = new Dictionary<int, string>();
protected override async Task OnInitializedAsync()
{
	users = await TestService.GetUsers(new Query { Expand = "Department" });
	offices = (await TestService.GetOfficesGetalls())
		.ToDictionary(key => key.OfficeID, value => value.OfficeName);
}

Then I added a <Template> tag in the RadzenDataGridColumn for OfficeID.

Snippet from Users.razor

<RadzenDataGridColumn TItem="TestDropDownList.Models.Test.User" Property="OfficeID" Title="Office I D">
	<Template Context="user">
		@offices[user.OfficeID]
	</Template>
</RadzenDataGridColumn>

Code works as I want but there's a problem in design mode. The RadzenDataGrid disappears from the layout if the line @offices[user.OfficeID] exists. If I remove it, the layout is find. See the attached pictures.

If that line is removed.

If that line exists.

This is just a simple case to demonstrate what I'm doing. The real case is a bit more complex with lots of drop down columns having views or stored procedure as their data source (obviously I can't make relationships between tables and views/stored procedures). If you have better solutions, please do tell me.

Thank you.