In Development
Last Updated: 10 Jan 2025 10:35 by ADMIN
Scheduled for 2025 Q1 (February)
Martin Ivanov
Created on: 18 Dec 2024 09:24
Category: GridView
Type: Bug Report
1
GridView: The CheckBox in the header of GridViewSelectColumn is not checked on the first click when grouping is applied

The GridViewSelectColumn displays a CheckBox in its header, which selects all rows in the column. If the CheckBox is unchecked, and you click it to check the items, the items get selected/checked. However, the CheckBox doesn't get check until the second click.

This reproduces only when the RadGridView is grouped and also the groups are collapsed so that no data records are visible.

To work this around, you can replace the default CheckBox with a new one in the column's Header. Then, manually select and deselect the items. You can use the CheckBox MouseLeftButtonDown or Checked/Unchecked events. Note that it is important to wrap the CheckBox in the Header, in another control (like a Grid in the example below), in order to avoid the default RadGridView logic to kick-in.

  <telerik:GridViewSelectColumn>
      <telerik:GridViewSelectColumn.Header>
          <Grid>
              <CheckBox PreviewMouseLeftButtonDown="CheckBox_PreviewMouseLeftButtonDown"/>
          </Grid>
      </telerik:GridViewSelectColumn.Header>
  </telerik:GridViewSelectColumn>


 private void CheckBox_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     var checkBox = (CheckBox)sender;            
     if (checkBox.IsChecked.Value)
     {
         this.GridView.SelectedItems.Clear();
     }
     else
     {
         this.GridView.SelectAll();
     }
 }

 

0 comments