using Connected.Utilities;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
namespace Connected.Components;
public partial class THeadRow : UIComponent
{
protected string Classname => new CssBuilder("mud-table-row")
.AddClass(Class).Build();
[CascadingParameter] public TableContext Context { get; set; }
[Parameter] public RenderFragment ChildContent { get; set; }
///
/// Add a multi-select checkbox that will select/unselect every item in the table
///
[Parameter] public bool IsCheckable { get; set; }
///
/// Specify behavior in case the table is multi-select mode. If set to true
, it won't render an additional empty column.
///
[Parameter] public bool IgnoreCheckbox { get; set; }
///
/// Specify behavior in case the table is editable. If set to true
, it won't render an additional empty column.
///
[Parameter] public bool IgnoreEditable { get; set; }
[Parameter] public bool IsExpandable { get; set; }
///
/// On click event
///
[Parameter] public EventCallback OnRowClick { get; set; }
private bool _checked;
public bool IsChecked
{
get => _checked;
set
{
if (value != _checked)
{
_checked = value;
if (IsCheckable)
Context.Table.OnHeaderCheckboxClicked(value);
}
}
}
protected override Task OnInitializedAsync()
{
Context?.HeaderRows.Add(this);
return base.OnInitializedAsync();
}
public void Dispose()
{
Context?.HeaderRows.Remove(this);
}
public void SetChecked(bool b, bool notify)
{
if (notify)
IsChecked = b;
else
{
_checked = b;
if (IsCheckable)
InvokeAsync(StateHasChanged);
}
}
}