Browse Source

custom component support for table columns

pull/7686/head
Ilkay Ilknur 5 years ago
parent
commit
c8ebda30ab
  1. 2
      framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumn.cs
  2. 10
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor
  3. 34
      framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs
  4. 6
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs
  5. 16
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleNameComponent.razor
  6. 9
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleNameComponent.razor.cs

2
framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Volo/Abp/AspNetCore/Components/Extensibility/TableColumns/TableColumn.cs

@ -11,7 +11,7 @@ namespace Volo.Abp.AspNetCore.Components.Extensibility.TableColumns
public string Title { get; set; }
public string Data { get; set; }
[CanBeNull]
public Func<object, RenderFragment> Render { get; set; }
public Type Component { get; set; }
public List<EntityAction> Actions { get; set; }
public TableColumn()

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

@ -27,14 +27,16 @@
RequiredPolicy="@action.RequiredPolicy"
Clicked="async () => await action.Clicked(context)"
ConfirmationMessage="() => action.ConfirmationMessage.Invoke(context)"
Text="@action.Text"></EntityAction>
Text="@action.Text">
</EntityAction>
}
else
{
<EntityAction TItem="TItem"
RequiredPolicy="@action.RequiredPolicy"
Clicked="async () => await action.Clicked(context)"
Text="@action.Text"></EntityAction>
Text="@action.Text">
</EntityAction>
}
}
</EntityActions>
@ -43,11 +45,11 @@
}
else
{
@if (column.Render != null)
@if (column.Component != null)
{
<DataGridColumn TItem="TItem" Field="@column.Data" Caption="@column.Title">
<DisplayTemplate>
@column.Render.Invoke(context)
@RenderCustomTableColumnComponent(column.Component, context);
</DisplayTemplate>
</DataGridColumn>
}

34
framework/src/Volo.Abp.BlazoriseUI/Components/AbpExtensibleDataGrid.razor.cs

@ -1,32 +1,38 @@
using System;
using Blazorise.Extensions;
using Blazorise.DataGrid;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using JetBrains.Annotations;
using Volo.Abp.AspNetCore.Components.Extensibility.TableColumns;
namespace Volo.Abp.BlazoriseUI.Components
{
public partial class AbpExtensibleDataGrid<TItem> : ComponentBase
{
protected Dictionary<string, DataGridEntityActionsColumn<TItem>> ActionColumns = new Dictionary<string, DataGridEntityActionsColumn<TItem>>();
protected Dictionary<string, DataGridEntityActionsColumn<TItem>> ActionColumns =
new Dictionary<string, DataGridEntityActionsColumn<TItem>>();
[Parameter]
public IEnumerable<TItem> Data { get; set; }
[Parameter] public IEnumerable<TItem> Data { get; set; }
[Parameter]
public EventCallback<DataGridReadDataEventArgs<TItem>> ReadData { get; set; }
[Parameter] public EventCallback<DataGridReadDataEventArgs<TItem>> ReadData { get; set; }
[Parameter]
public int? TotalItems { get; set; }
[Parameter] public int? TotalItems { get; set; }
[Parameter]
public bool ShowPager { get; set; }
[Parameter] public bool ShowPager { get; set; }
[Parameter]
public int PageSize { get; set; }
[Parameter] public int PageSize { get; set; }
[Parameter]
public IEnumerable<TableColumn> Columns { get; set; }
[Parameter] public IEnumerable<TableColumn> Columns { get; set; }
protected RenderFragment RenderCustomTableColumnComponent(Type type, object data)
{
return (builder) =>
{
builder.OpenComponent(type);
builder.AddAttribute(0, "Data", data);
builder.CloseComponent();
};
}
}
}
}

6
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Blazorise.Extensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
@ -95,7 +94,8 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
{
Title = L["RoleName"],
Data = nameof(IdentityRoleDto.Name),
Render = (data) =>
Component = typeof(RoleNameComponent)
/*Render = (data) =>
{
return (builder) =>
{
@ -128,7 +128,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
builder.CloseComponent();
}
};
}
}*/
},
});

16
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleNameComponent.razor

@ -0,0 +1,16 @@
@using System;
@using Volo.Abp.Identity
@using Microsoft.Extensions.Localization
@using Volo.Abp.Identity.Localization
@inject IStringLocalizer<IdentityResource> L
@(Data.As<IdentityRoleDto>().Name)
@if (Data.As<IdentityRoleDto>().IsDefault)
{
<Badge Color="Color.Primary" Margin="Margin.Is1.FromLeft">@L["DisplayName:IsDefault"]</Badge>
}
@if (Data.As<IdentityRoleDto>().IsPublic)
{
<Badge Color="Color.Light" Margin="Margin.Is1.FromLeft">@L["DisplayName:IsPublic"]</Badge>
}

9
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleNameComponent.razor.cs

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Components;
namespace Volo.Abp.Identity.Blazor.Pages.Identity
{
public partial class RoleNameComponent : ComponentBase
{
[Parameter] public object Data { get; set; }
}
}
Loading…
Cancel
Save