Merge pull request #8474 from abpframework/auto-merge/rel-4-3/247

Merge branch dev with rel-4.3
pull/8546/head
maliming 5 years ago committed by GitHub
commit f7f079dca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,8 @@ To avoid manual effort, we might use a tool like [NSWAG](https://github.com/Rico
ABP introduces an endpoint that exposes server-side method contracts. When the `generate-proxy` command is run, ABP CLI makes an HTTP request to this endpoint and generates better-aligned client proxies in TypeScript. It organizes folders according to namespaces, adds barrel exports, and reflects method signatures in Angular services. ABP introduces an endpoint that exposes server-side method contracts. When the `generate-proxy` command is run, ABP CLI makes an HTTP request to this endpoint and generates better-aligned client proxies in TypeScript. It organizes folders according to namespaces, adds barrel exports, and reflects method signatures in Angular services.
> Before you start, please make sure you start the backend application with `dotnet run`. There is a [known limitation about Visual Studio](#known-limitations), so please do not run the project using its built-in web server.
Run the following command in the **root folder** of the angular application: Run the following command in the **root folder** of the angular application:
```bash ```bash

@ -1,6 +1,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions; using Volo.Abp.AspNetCore.Components.Web.Extensibility.EntityActions;
namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns
@ -11,11 +12,13 @@ namespace Volo.Abp.AspNetCore.Components.Web.Extensibility.TableColumns
public string Data { get; set; } public string Data { get; set; }
[CanBeNull] [CanBeNull]
public string DisplayFormat { get; set; } public string DisplayFormat { get; set; }
public IFormatProvider DisplayFormatProvider { get; set; } = CultureInfo.CurrentCulture;
[CanBeNull] [CanBeNull]
public Type Component { get; set; } public Type Component { get; set; }
public List<EntityAction> Actions { get; set; } public List<EntityAction> Actions { get; set; }
[CanBeNull] [CanBeNull]
public Func<object,string> ValueConverter { get; set; } public Func<object,string> ValueConverter { get; set; }
public bool Sortable { get; set; }
public TableColumn() public TableColumn()
{ {

@ -62,7 +62,26 @@
{ {
if (!ExtensionPropertiesRegex.IsMatch(column.Data)) if (!ExtensionPropertiesRegex.IsMatch(column.Data))
{ {
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title"/> @if (column.ValueConverter == null)
{
<DataGridColumn TItem="TItem"
Field="@column.Data"
Caption="@column.Title"
Sortable="@column.Sortable"
DisplayFormat="@column.DisplayFormat"
DisplayFormatProvider="@column.DisplayFormatProvider"/>
}
else
{
<DataGridColumn TItem="TItem"
Field="@column.Data"
Caption="@column.Title"
Sortable="@column.Sortable">
<DisplayTemplate>
@(GetConvertedFieldValue(context, column))
</DisplayTemplate>
</DataGridColumn>
}
} }
else else
{ {
@ -87,14 +106,7 @@
{ {
if (column.ValueConverter != null) if (column.ValueConverter != null)
{ {
if (column.DisplayFormat == null) @(GetConvertedFieldValue(context, column))
{
@(column.ValueConverter(propertyValue))
}
else
{
@(string.Format(column.DisplayFormat, column.ValueConverter(propertyValue)))
}
} }
else else
{ {
@ -104,10 +116,9 @@
} }
else else
{ {
@(string.Format(column.DisplayFormat, propertyValue)) @(string.Format(column.DisplayFormatProvider, column.DisplayFormat, propertyValue))
} }
} }
} }
} }
</DisplayTemplate> </DisplayTemplate>

@ -46,5 +46,17 @@ namespace Volo.Abp.BlazoriseUI.Components
builder.CloseComponent(); builder.CloseComponent();
}; };
} }
protected virtual string GetConvertedFieldValue(TItem item, TableColumn columnDefinition)
{
var convertedValue = columnDefinition.ValueConverter.Invoke(item);
if (!columnDefinition.DisplayFormat.IsNullOrEmpty())
{
return string.Format(columnDefinition.DisplayFormatProvider, columnDefinition.DisplayFormat,
convertedValue);
}
return convertedValue;
}
} }
} }
Loading…
Cancel
Save