ant-design-blazor/components/table/Column.razor.cs
James Yeung 7e7d63aaec feat(module: table): add pagination and empty (#175)
* refactor: add ChildContent and title for column

* feat: add pagination and empty

* feat(module: table): add officeial demo

* fix: indent
2020-06-02 19:15:15 +08:00

53 lines
1.3 KiB
C#

using System;
using System.Linq.Expressions;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
namespace AntDesign
{
public partial class Column<TItem> : AntComponentBase, ITableColumn
{
[Parameter]
public string Title { get; set; }
[Parameter]
public TItem Field { get; set; }
[Parameter]
public EventCallback<TItem> FieldChanged { get; set; }
[Parameter]
public Expression<Func<TItem>> FieldExpression { get; set; }
[Parameter]
public bool Sort { get; set; }
[Parameter]
public RenderFragment<TItem> CellRender { get; set; }
[Parameter]
public RenderFragment ChildContent { get; set; }
[CascadingParameter]
public ITable Table { get; set; }
[CascadingParameter(Name = "IsHeader")]
public bool IsHeader { get; set; }
private FieldIdentifier? _fieldIdentifier;
public string DisplayName => _fieldIdentifier?.GetDisplayName();
public string FieldName => _fieldIdentifier?.FieldName;
protected override void OnInitialized()
{
if (FieldExpression != null)
{
_fieldIdentifier = FieldIdentifier.Create(FieldExpression);
}
Table?.AddColumn(this);
}
}
}