FlexGrid/CheckListBehavior selection changed?

Posted by: pkillick on 26 January 2023, 7:17 am EST

  • Posted 26 January 2023, 7:17 am EST

    I’m using in Flex grid. Is there an event or Razor parameter that will tell me when any of the item selections change? The existing SelectionChanged and related properties and events appear to be for the cell/column/row style of selection only.

  • Posted 30 January 2023, 5:47 am EST

    Hi,

    Thank you for your patience, by default there is no such event, we are investigating on this and we will update you soon on this.

    Regards,

    Manish Gupta

  • 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

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels