CheckBox in Header for select all

Hello
I have sfGrid with GridCheckBoxColumn. 
Target what i want to achieve is checkbox in header wich make select or unselect all comboboxes below.
Now i have only text in header.


1 Reply 1 reply marked as answer

MA Mohanram Anbukkarasu Syncfusion Team November 26, 2020 06:38 AM UTC

Hi Marcin, 

Thanks for contacting Syncfusion support. 

You can achieve your requirement to display check box on the header cell of the GridCheckBoxColumn by using the HeaderTemplate support in SfDataGrid as shown in the following code example.  

Code example :  

<syncfusion:SfDataGrid.Columns> 
    <syncfusion:GridCheckBoxColumn MappingName="IsClosed"> 
        <syncfusion:GridCheckBoxColumn.HeaderTemplate> 
            <DataTemplate> 
                <StackPanel Orientation="Horizontal"> 
                    <CheckBox Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged" IsChecked="{x:Null}" HorizontalAlignment="Center" VerticalAlignment="Bottom"/> 
                   <TextBlock Text="Closed" Margin="20,0,0,0"/> 
                </StackPanel> 
            </DataTemplate> 
        </syncfusion:GridCheckBoxColumn.HeaderTemplate> 
    </syncfusion:GridCheckBoxColumn> 
 
private void CheckBox_CheckedChanged(object sender, RoutedEventArgs e) 
{ 
    var collection = (this.DataContext as ViewModel).OrdersListDetails; 
 
    foreach(var item in collection) 
    { 
        (item as OrderInfo).IsClosed = (bool)(sender as CheckBox).IsChecked; 
    } 
} 



Please let us know if you require further assistance from us. 

Regards, 
Mohanram A. 


Marked as answer
Loader.
Up arrow icon