- ABP Framework version: v8.0.0
- UI Type: Blazor Server
- Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace:
- Steps to reproduce the issue: In UserManagement page I want to hide some extra property, can I overwrite ExtensionProperties component? I tried to hide field but it does not work user.AddOrUpdateProperty<string>( //property type: string UserConsts.TokenPropertyName, //property name property => { //validation rules property.Attributes.Add(new StringLengthAttribute(UserConsts.TokenMaxLength)); property.UI.OnEditForm.IsVisible = false; property.UI.OnCreateForm.IsVisible = false; property.Configuration["AllowUserToEdit"] = false; } );
16 Answer(s)
-
0
hi
Yes, you can override this component.
https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components?UI=BlazorServer
The source code: https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor.cs#L9 https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.BlazoriseUI/Components/ObjectExtending/ExtensionProperties.razor
-
0
Can you give me snipper code to overwrite this component? I just manually hide some specific field eg if (!propertyInfo.Name.EndsWith("_Text")) => if (!propertyInfo.Name.EndsWith("_Text") && !propertyInfo.Name.Equals("Token"))
OR alternative solution is give me source code of UserManagement page in Pro module so I disable ExtraProperties
-
0
sure, what's your email?
I will share the source code of
UserManagement
component. -
0
Can you share me to lan.dang@kwork.fi ? Thank you
-
0
Hi
I have sent the mail.
-
0
-
0
hi
Add below namespaces to your
_Imports.razor
file:@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Forms @using Volo.Abp.AspNetCore.Components.Web @using Volo.Abp.BlazoriseUI @using Volo.Abp.BlazoriseUI.Components @using Blazorise @using Blazorise.DataGrid @using Excubo.Blazor.TreeViews @using Volo.Abp.Identity.Pro.Blazor.Pages.Identity.Components;
-
0
I just sent you email, could you help me check what I was wrong
Thank you
-
0
hi
Can you share a minimal project so I can debug it.
Thanks.
-
0
I get hard to make a minimal project. I try to solve the problem with some modify, As per this document : https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components?UI=BlazorServer Could we modify in both razor and code behind?
I want to update UI and overwrite some method in code behind as well Where do I put this code line? [ExposeServices(typeof(UserManagement))] [Dependency(ReplaceServices = true)]
-
0
hi
Could we modify in both razor and code behind?
Yes.
Where do I put this code line?
In your blazor project, eg the
Component
folder. -
0
I mean, if i put this code in razor page it will not hit razor.cs (code behind) @inherits UserManagement @attribute [ExposeServices(typeof(UserManagement))] @attribute [Dependency(ReplaceServices = true)]
But if i put this code in razor.cs it does not update UI from razor page [ExposeServices(typeof(UserManagement))] [Dependency(ReplaceServices = true)]
I want to update both razor and razor.cs file. How can I do that?
-
0
hi
I will share the code. wait a monent.
-
0
hi
You can add your code to
MyExtensionProperties.razor
MyExtensionProperties.razor
@typeparam TEntityType @typeparam TResourceType @using Volo.Abp.Data @using Volo.Abp.ObjectExtending @inherits Volo.Abp.BlazoriseUI.Components.ObjectExtending.ExtensionProperties<TEntityType, TResourceType> @{ Entity.SetDefaultsForExtraProperties(); foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties<TEntityType>()) { if (!propertyInfo.Name.EndsWith("_Text")) { if (propertyInfo.Type.IsEnum) { <SelectExtensionProperty PropertyInfo="@propertyInfo" Entity="@Entity" TEntity="TEntityType" TResourceType="TResourceType" LH="@LH" /> } else if (!propertyInfo.Lookup.Url.IsNullOrEmpty()) { <LookupExtensionProperty PropertyInfo="@propertyInfo" Entity="@Entity" TEntity="TEntityType" TResourceType="TResourceType" LH="@LH" /> } else { var inputType = BlazoriseUiObjectExtensionPropertyInfoExtensions.GetInputType(propertyInfo); __builder.OpenComponent(0, inputType.MakeGenericType(new[] { typeof(TEntityType), typeof(TResourceType) })); __builder.AddAttribute(1, "PropertyInfo", propertyInfo); __builder.AddAttribute(2, "Entity", Entity); __builder.AddAttribute(3, "LH", LH); __builder.AddAttribute(4, "ModalType", ModalType); __builder.CloseComponent(); } } } }
MyExtensionProperties.razor.cs
using Volo.Abp.BlazoriseUI.Components.ObjectExtending; using Volo.Abp.Data; namespace BookStore.Blazor.Components; public partial class MyExtensionProperties<TEntityType, TResourceType> : ExtensionProperties<TEntityType, TResourceType> where TEntityType : IHasExtraProperties { }
Replace the
ExtensionProperties
in DI.public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.Replace(ServiceDescriptor.Transient( typeof(ExtensionProperties<IdentityUserCreateDto, IdentityResource>), typeof(MyExtensionProperties<IdentityUserCreateDto, IdentityResource>))); context.Services.Replace(ServiceDescriptor.Transient( typeof(ExtensionProperties<IdentityUserUpdateDto, IdentityResource>), typeof(MyExtensionProperties<IdentityUserUpdateDto, IdentityResource>))); }
-
0
Thank a lot , it solves my requirement
-
0
Good news.