diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 3550213041..b434fa4407 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -15,9 +15,10 @@ using Volo.Abp.Application.Services; using Volo.Abp.AspNetCore.Components; using Volo.Abp.AspNetCore.Components.Extensibility.EntityActions; using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns; -using Volo.Abp.AspNetCore.Components.WebAssembly; +using Volo.Abp.Localization; using Volo.Abp.Authorization; using Volo.Abp.BlazoriseUI.Components; +using Volo.Abp.ObjectExtending.Modularity; namespace Volo.Abp.BlazoriseUI { @@ -478,10 +479,39 @@ namespace Volo.Abp.BlazoriseUI { return ValueTask.CompletedTask; } - + protected virtual ValueTask SetToolbarItemsAsync() { return ValueTask.CompletedTask; } + + protected virtual IEnumerable GetExtensionTableColumns(string moduleName, string entityType) + { + var properties = ModuleExtensionConfigurationHelper.GetPropertyConfigurations(moduleName, entityType); + foreach (var propertyInfo in properties) + { + if (propertyInfo.IsAvailableToClients && propertyInfo.UI.OnTable.IsVisible) + { + if (propertyInfo.Name.EndsWith("_Text")) + { + var lookupPropertyName = propertyInfo.Name.RemovePostFix("_Text"); + var lookupPropertyDefinition = properties.SingleOrDefault(t => t.Name == lookupPropertyName); + yield return new TableColumn + { + Title = lookupPropertyDefinition.GetLocalizedDisplayName(StringLocalizerFactory), + Data = $"ExtraProperties[{propertyInfo.Name}]" + }; + } + else + { + yield return new TableColumn + { + Title = propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory), + Data = $"ExtraProperties[{propertyInfo.Name}]" + }; + } + } + } + } } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor index a66831f051..0bc49f6b4f 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor @@ -1,7 +1,7 @@ @typeparam TItem @using Blazorise.DataGrid; -@using Volo.Abp.AspNetCore.Components.Extensibility - +@using Volo.Abp.Data +@using Volo.Abp.BlazoriseUI.Components.ObjectExtending + @RenderCustomTableColumnComponent(column.Component, context) @@ -55,7 +55,24 @@ } else { - + if (!ExtensionPropertiesRegex.IsMatch(column.Data)) + { + + } + else + { + + + @{ + var entity = context as IHasExtraProperties; + var propertyName = ExtensionPropertiesRegex.Match(column.Data).Groups[1].Value; + var propertyValue = entity.GetProperty(propertyName); + @(propertyValue) + } + + + } + } } } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs index 08df590bfd..f1e94a7c7e 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs @@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Components; using System.Collections.Generic; using JetBrains.Annotations; using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns; +using System.Linq; +using System.Text.RegularExpressions; namespace Volo.Abp.BlazoriseUI.Components { @@ -15,6 +17,8 @@ namespace Volo.Abp.BlazoriseUI.Components protected Dictionary> ActionColumns = new Dictionary>(); + protected Regex ExtensionPropertiesRegex = new Regex(@"ExtraProperties\[(.*?)\]"); + [Parameter] public IEnumerable Data { get; set; } [Parameter] public EventCallback> ReadData { get; set; }