using Microsoft.AspNetCore.Components;
namespace Connected.Components;
///
/// Binds an object's property to a column by its property name
///
public partial class SortableColumn : ColumnBase
{
T InternalValue
{
get => Value;
set
{
if (!EqualityComparer.Default.Equals(value, Value))
{
Value = value;
ValueChanged.InvokeAsync(value);
}
}
}
///
/// Specifies the name of the object's property bound to the column
///
[Parameter] public T Value { get; set; }
[Parameter] public EventCallback ValueChanged { get; set; }
///
/// Specifies the name of the object's property bound to the footer
///
[Parameter]
public T FooterValue
{
get { return _footerValue; }
set { _footerValue = value; _footerValueAvailable = true; }
}
private T _footerValue;
private bool _footerValueAvailable = false;
///
/// Used if no FooterValue is available
///
[Parameter] public string FooterText { get; set; }
///
/// Specifies which string format should be used.
///
[Parameter] public string DataFormatString { get; set; }
///
/// Specifies if the column should be readonly even if the DataTable is in editmode.
///
[Parameter] public bool ReadOnly { get; set; }
[Parameter] public string SortLabel { get; set; }
[Parameter] public Func SortBy { get; set; } = default;
private string GetFormattedString(T item)
{
if (DataFormatString != null)
{
return string.Format(DataFormatString, item);
}
else
{
return item?.ToString();
}
}
}