ant-design-blazor/components/table/Column.razor.cs
James Yeung 63d09f76a5 feat(module: table): add selection (#190)
* feat: add pagination and empty

* fix: indent

* feat(module: table): add checkbox selection

* feat(module: table): add radio selection

* feat: add selected rows
2020-06-05 16:06:23 +08:00

67 lines
1.6 KiB
C#

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