Browse Source

Merge pull request #16172 from abpframework/AbpExtensibleDataGrid

Add `PropertyName` and use it as sort field.
pull/16189/head
liangshiwei 4 years ago
committed by GitHub
parent
commit
bd5667bb53
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs
  2. 8
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  3. 2
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

8
framework/src/Volo.Abp.AspNetCore.Components.Web/Volo/Abp/AspNetCore/Components/Web/Extensibility/TableColumns/TableColumn.cs

@ -10,14 +10,22 @@ public class TableColumn
{
public string Title { get; set; }
public string Data { get; set; }
public string PropertyName { get; set; }
[CanBeNull]
public string DisplayFormat { get; set; }
public IFormatProvider DisplayFormatProvider { get; set; } = CultureInfo.CurrentCulture;
[CanBeNull]
public Type Component { get; set; }
public List<EntityAction> Actions { get; set; }
[CanBeNull]
public Func<object, string> ValueConverter { get; set; }
public bool Sortable { get; set; }
public TableColumn()

8
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -309,7 +309,7 @@ public abstract class AbpCrudPageBase<
{
CurrentSorting = e.Columns
.Where(c => c.SortDirection != SortDirection.Default)
.Select(c => c.Field + (c.SortDirection == SortDirection.Descending ? " DESC" : ""))
.Select(c => c.SortField + (c.SortDirection == SortDirection.Descending ? " DESC" : ""))
.JoinAsString(",");
CurrentPage = e.Page;
@ -608,7 +608,8 @@ public abstract class AbpCrudPageBase<
yield return new TableColumn
{
Title = lookupPropertyDefinition.GetLocalizedDisplayName(StringLocalizerFactory),
Data = $"ExtraProperties[{propertyInfo.Name}]"
Data = $"ExtraProperties[{propertyInfo.Name}]",
PropertyName = propertyInfo.Name
};
}
else
@ -616,7 +617,8 @@ public abstract class AbpCrudPageBase<
var column = new TableColumn
{
Title = propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory),
Data = $"ExtraProperties[{propertyInfo.Name}]"
Data = $"ExtraProperties[{propertyInfo.Name}]",
PropertyName = propertyInfo.Name
};
if (propertyInfo.IsDate() || propertyInfo.IsDateTime())

2
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor

@ -105,7 +105,7 @@
}
else
{
<DataGridColumn TItem="TItem" Field="@nameof(IHasExtraProperties.ExtraProperties)" Caption="@column.Title">
<DataGridColumn TItem="TItem" Field="@nameof(IHasExtraProperties.ExtraProperties)" SortField="@column.PropertyName" Caption="@column.Title">
<DisplayTemplate>
@{
var entity = context as IHasExtraProperties;

Loading…
Cancel
Save