59 lines
1.1 KiB
C#
59 lines
1.1 KiB
C#
using System;
|
|
|
|
namespace zero.Core.Utils
|
|
{
|
|
public class TableColumn<T>
|
|
{
|
|
public string Name { get; set; }
|
|
|
|
public bool IsSeparator { get; set; }
|
|
|
|
public Func<T, object> FieldSelector { get; set; }
|
|
|
|
public Func<T, bool> CanRender { get; set; } = x => true;
|
|
|
|
public double Width { get; set; }
|
|
|
|
public TableColumnType ColumnType { get; set; }
|
|
|
|
public TableColumn<T> Type(TableColumnType type)
|
|
{
|
|
ColumnType = type;
|
|
return this;
|
|
}
|
|
|
|
public TableColumn<T> Size(double width)
|
|
{
|
|
Width = width;
|
|
return this;
|
|
}
|
|
|
|
public TableColumn<T> For(Func<T, object> fieldSelector, Func<T, bool> canRender = null)
|
|
{
|
|
FieldSelector = fieldSelector;
|
|
CanRender = canRender ?? CanRender;
|
|
return this;
|
|
}
|
|
|
|
public TableColumn<T> Currency()
|
|
{
|
|
ColumnType = TableColumnType.Currency;
|
|
return this;
|
|
}
|
|
|
|
public TableColumn<T> Link()
|
|
{
|
|
ColumnType = TableColumnType.Link;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
public enum TableColumnType
|
|
{
|
|
Default,
|
|
Currency,
|
|
Link
|
|
}
|
|
}
|