Posted 31 January 2023, 5:08 am EST
Hi Paul,
When the CheckList is checked or unchecked, there is no event by default. However, you could customise the Grid Column and use the C1CheckBox for your custom column for your use case.
Create a Custom Column that inherits the GridColumn Class, then overwrite the “GetCellContentRenderFragment” method to use the C1CheckBox instead of a Text Editor. Bind the C1CheckBox’s “IsCheckedChanged” property and use the EventCallBack to pass the checked/unchecked status from the C1CheckBox to the Grid.
Please see the attached sample and the code below to see how this is done:
public class CustomCheckBoxColumn : GridColumn
{
[Parameter]
public EventCallback<bool> OnCheckedChange { get; set; }
protected override RenderFragment GetCellContentRenderFragment(GridCellType cellType, GridRow row)
{
if (cellType == GridCellType.Cell)
{
return new RenderFragment(builder =>
{
var value = Grid[row, this];
builder.OpenComponent<C1CheckBox>(0);
builder.AddAttribute(2, nameof(C1CheckBox.IsCheckedChanged), new EventCallback<bool?>(null, CheckedChanged));
builder.CloseComponent();
});
}
return base.GetCellContentRenderFragment(cellType, row);
}
private async void CheckedChanged(bool e)
{
await OnCheckedChange.InvokeAsync(e);
}
}
You may download the sample using the following link: https://drive.google.com/file/d/1p0wppX2oUM9XfIwhByrZpt4yY3LABAkG/view?usp=share_link
References:
GridColumn Class: https://www.grapecity.com/componentone/docs/blazor/online-blazor/C1.Blazor.Grid~C1.Blazor.Grid.GridColumn.html
IsCheckedChanged Property: https://www.grapecity.com/componentone/docs/blazor/online-blazor/C1.Blazor.Core~C1.Blazor.Core.C1CheckBox~IsCheckedChanged.html
GridColumnCustomization Demo: https://www.grapecity.com/componentone/demos/blazor/blazorexplorer/FlexGrid/CustomDropDownColumn
Regards,
Ankit