GridColumn Type ColumnType.CheckBox What event should I define when all are selected or all are not selected


Image_9325_1718784201788


I want to make the chart data invisible when deselecting all.


Image_4448_1718784675576


public async Task Grid_master_RowSelect(RowSelectEventArgs<Examine_chart_de> args)

{

    args.Data.examine_chk = true;

    var dataSource = Examine_chart_row;

    int i = 0;

    foreach (var chartdata in dataSource)

    {

        if (args.Data.gtw_id == chartdata.gtw_id)

        {

            //chartdata.visible_val = args.Data.examine_chk;

            SeriesCollection[i].visible_val = true;

        }

        i++;

    }

    StateHasChanged();

}


public async Task Grid_master_RowDeselect(RowDeselectEventArgs<Examine_chart_de> args)

{

    args.Data.examine_chk = false;

    var dataSource = Examine_chart_row;

    int i = 0;

    foreach (var chartdata in dataSource)

    {

        if (args.Data.gtw_id == chartdata.gtw_id)

        {

            //chartdata.visible_val = args.Data.examine_chk;

            SeriesCollection[i].visible_val = false;

        }

        i++;

    }

    StateHasChanged();

}


    • I don't know how to define and apply events when deselecting all and deselecting all.




1 Reply 1 reply marked as answer

PS Prathap Senthil Syncfusion Team June 20, 2024 12:07 PM UTC

Hi,

Based on your requirement to ensure that all records are selected or not selected, we suggest using the RowSelected and RowDeSelected events along with the IsHeaderCheckboxClicked property. This will help you meet your requirement. Kindly refer to the sample and API link below for your reference.

 

<SfGrid DataSource="@Orders" AllowSelection="true" AllowPaging="true">

    <GridSelectionSettings Type="Syncfusion.Blazor.Grids.SelectionType.Multiple"></GridSelectionSettings>

    <GridEvents RowSelected="RowSelectHandler" RowDeselected="RowDeselectHandler" TValue="Order"></GridEvents>

</SfGrid>

 

 

 

@code {

 

    public void RowSelectHandler(Syncfusion.Blazor.Grids.RowSelectEventArgs<Order> args)

    {

        if (args.IsHeaderCheckboxClicked)

        {

            // Here, you can customize your code.

        }

 

    }

 

    public void RowDeselectHandler(Syncfusion.Blazor.Grids.RowDeselectEventArgs<Order> args)

    {

        if (args.IsHeaderCheckboxClicked)

        {

            // Here, you can customize your code.

        }

    }

}


Sample:
https://blazorplayground.syncfusion.com/embed/hZrfDdrXguoDDqlC?appbar=true&editor=true&result=true&errorlist=true&theme=material-dark


Api Link: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.RowSelectEventArgs-1.html#Syncfusion_Blazor_Grids_RowSelectEventArgs_1_IsHeaderCheckboxClicked

Regards,
Prathap Senthil


Marked as answer
Loader.
Up arrow icon