Hi,
if I add the "role" property as a column to the users grid it is always empty:
robert
The role property is in this case a list of objects. Radzen cannot just display a list of something without knowing what propery to show.
Can you show me the propery Role on the User object then i can help you further
I want to show the Name of all assigned roles - it seems that the Roles collection is always empty?
Do you assign any roles?
sure - there are many entries with roles
Roles are empty as they are not included by default. Here is how to display them.
public async Task<IEnumerable<ApplicationUser>> GetUsers()
{
var uri = new Uri(baseUri, $"ApplicationUsers");
uri = uri.GetODataUri(expand:"Roles"); // Get the roles as well
var response = await httpClient.GetAsync(uri);
var result = await response.ReadAsync<ODataServiceResult<ApplicationUser>>();
return result.Value;
}
<RadzenDataGridColumn TItem="YourApp.Models.ApplicationUser" Property="Roles">
<Template>
@string.Join(", ", context.Roles.Select(r => r.Name))
</Template>
</RadzenDataGridColumn>
The final result would look like this:
Thanks a lot - it works