- ABP Framework version: v8.0.3
- UI Type: Blazor WASM
Hello, I'm overriding the page UserManagement
and I would like to add new columns to the table such as Address, City etc. to the IdentityUser
I thought I can use the property ExtraProperties
to add my custom properties but then I'm not sure how can I access my custom keys in TableColumn Data property?
This is what I have so far but it didn't work for me:
Error:
System.ArgumentException: Cannot detect the member of Volo.Abp.Data.ExtraPropertyDictionary (Parameter 'Address')
at Blazorise.DataGrid.Utils.FunctionCompiler.GetSafePropertyOrField(Expression item, String propertyOrFieldName)
at Blazorise.DataGrid.Utils.FunctionCompiler.GetSafePropertyOrField(Expression item, String propertyOrFieldName)
at Blazorise.DataGrid.Utils.FunctionCompiler.CreateValueGetter[IdentityUserDto](String fieldName)
at Blazorise.DataGrid.DataGridColumn`1[[Volo.Abp.Identity.IdentityUserDto, Volo.Abp.Identity.Pro.Application.Contracts, Version=8.0.3.0, Culture=neutral, PublicKeyToken=null]].<.ctor>b__10_2()
Adding extra properties by overriding the function GetEntitiesAsync
Is there something I'm doing wrong? I'm open for suggestions or other ways to achieve that
Note that my address, city etc. live in another table right now called UserProfile.
Thanks
4 Answer(s)
-
0
hi
The
AbpExtensibleDataGrid
support theExtraProperties
, see https://docs.abp.io/en/abp/latest/Object-ExtensionsCan you share all your custom code?
-
0
Hi maliming
I saw that doc already, but I don't see any mention about AbpExtensibleDataGrid. I went to read some source code of yours and I found that a way to achieve that was to use Data and PropertyName at the same time.
But right now, I have another issue with the sorting, whenever I want to sort this ExtraProperty, it says:
No property or field 'Addresss' exists in type 'IdentityUser'
So I assume the AbpExtensibleDataGrid uses backend to sort and since Address is indeed not a column in my entity, it fails.
Do you have any clue how can I still sort but frontend only and avoid to sort backend for any "ExtraProperty" ?
My custom code has change since because I tried other ways but here's basically what it looks like:
Blazor.cs
[ExposeServices(typeof(UserManagement))] [Dependency(ReplaceServices = true)] public partial class MyUserManagement { [Inject] public required IUserProfileAppService UserProfileAppService { get; set; } protected override ValueTask SetTableColumnsAsync() { UserManagementTableColumns.AddRange( [ new TableColumn { Title = L["Email"], Data = "Email", Sortable = true }, // Here I consume and try to sort the extra property new TableColumn { Title = "Address", Data = "ExtraProperties[Address]", PropertyName = "Addresss", Sortable = true // <== this won't work! }, ]); UserManagementTableColumns.AddRange(GetExtensionTableColumns("Identity", "User")); return ValueTask.CompletedTask; } protected override async Task GetEntitiesAsync() { await base.GetEntitiesAsync(); await ExtendedEntities(); } private async Task ExtendedEntities() { // I act directly on the IdentityUserDto, because the extra properties come from another db table var userIds = Entities.Select(x => x.Id).ToList(); var userProfiles = await UserProfileAppService.GetListUserProfilesAsync(userIds); var userProfilesDict = userProfiles.ToDictionary(x => x.InternalUserId, x => x); foreach (var identityUserDto in Entities) { var profile = userProfilesDict.GetOrDefault(identityUserDto.Id); if (profile is null) { continue; } // Here I add the extra property identityUserDto.ExtraProperties["Address"] = profile.Address; } } }
-
0
hi
https://support.abp.io/QA/Questions/784/Filter-User-list-by-new-extra-property https://support.abp.io/QA/Questions/6721/Find-user-by-extend-property
-
0
hi
I saw you closed the question. Have you solved it?