GridViewCheckBox - cannot check / uncheck

1 Answer 43 Views
GridView
Licensing
Top achievements
Rank 1
Licensing asked on 22 Aug 2022, 09:58 AM

Hi,

I have created a RadGridView with a couple of columns (one of them being GridViewSelectColumn). I have also created a GroupDescriptor with GroupHeaderTemplate and I would like to add a GridViewCheckBox to the GroupHeaderTemplate, so I can select all items in a particular group by one click, however, the GridViewCheckBox is not enabled. I tried different properties on the control, but none of them works for me. 

If I add just a CheckBox then it works, but it does not have the style I need and I would not like to reproduce the Style already present on GridViewSelectColumn.

Can you advise how to enable the GridViewCheckBox ?

Thanks

            <telerik:RadGridView Grid.Row="1" ItemsSource="{Binding Collection}"
                                 AutoGenerateColumns="False"
                                 ShowGroupPanel="False"
                                 RowIndicatorVisibility="Collapsed"
                                 Padding="10"
                                 IsReadOnly="True"
                                 FrozenColumnsSplitterVisibility="Collapsed"
                                 IsFilteringAllowed="False"
                                 SelectionUnit="FullRow"
                                 SelectionMode="Extended">
                <telerik:RadGridView.GroupHeaderTemplate>

    <DataTemplate x:Key="SelectAllGroupHeaderTemplate">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <telerik:GridViewCheckBox VerticalAlignment="Center" HorizontalAlignment="Center">

            </telerik:GridViewCheckBox>
            <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="DemiBold"
                       Margin="10 0 0 0"
                       Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
                                       AncestorType={x:Type telerik:GridViewGroupRow}},
                                       Path=Group.Key}" />
        </StackPanel>
    </DataTemplate>


                </telerik:RadGridView.GroupHeaderTemplate>
                <telerik:RadGridView.GroupDescriptors>
                    <telerik:GroupDescriptor Member="Id"
                                             SortDirection="Ascending" />
                </telerik:RadGridView.GroupDescriptors>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewSelectColumn/>
                    <telerik:GridViewDataColumn Header="Date" MinWidth="150"
                                                DataMemberBinding="{Binding RollDate}" />
                    <telerik:GridViewDataColumn Header="ID" MinWidth="100"
                                                DataMemberBinding="{Binding Id}" />
                    <telerik:GridViewDataColumn Header="Name" MinWidth="220"
                                                DataMemberBinding="{Binding Name}" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </Grid>

1 Answer, 1 is accepted

Sort by
0
Accepted
Dilyan Traykov
Telerik team
answered on 24 Aug 2022, 10:17 AM

Hi,

Please allow me to elaborate on the purpose of the GridViewCheckBox control - it is designed to be displayed only in view mode and is not meant to be used for editing the bound values. It is used in the default cell template of the GridViewCheckBoxColumn and has a lightweight control template for improved performance.

Thus, if you need the checkbox to be functional, you need to use the native CheckBox element and style it appropriately. If you're using the standard Xaml binaries with the StyleManager theming approach, you need to set the attached StyleManager.Theme property of the control as explained in this article: Use StyleManager to Apply Theme on MS Controls.

<CheckBox telerik:StyleManager.Theme="Office_Black" VerticalAlignment="Center" HorizontalAlignment="Center" />

If you use the NoXaml assemblies with the implicit styles approach, the theme should be applied automatically for the CheckBox elements.

I hope you find this information helpful. Do let me know if any further questions or concerns arise.

Regards,
Dilyan Traykov
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Licensing
Top achievements
Rank 1
commented on 24 Aug 2022, 01:06 PM | edited

Hi,

thanks for your reply. I see, however, there is a checkbox embedded in GridViewSelectColumn - is it maybe available as a standalone control?

Regarding StyleManager - which theme should I use to get the desired output? The closest I got is with Expression_Dark theme. Is there any theme that would match the lower check box (the upper checkbox represents Expression_Dark theme)?

Dilyan Traykov
Telerik team
commented on 29 Aug 2022, 08:32 AM

Hi,

Generally speaking, you need to select the same theme set as the ApplicationTheme or otherwise used for the RadGridView control.

I prepared a small sample project where applying the Expression_Dark theme for the CheckBox control results in the same appearance for both the checkbox in the group header and those in the individual rows.

With this said, I assume there's some custom style applied to the cells of the GridViewSelectColumn. Can you please double-check if this is in fact the case?

If possible, please modify the sample project to demonstrate the appearance you observe at your end and I will gladly try to suggest how you can achieve a consistent look between the two types of checkboxes.

Licensing
Top achievements
Rank 1
commented on 30 Aug 2022, 05:46 AM

Thanks :) will check
Tags
GridView
Asked by
Licensing
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Share this question
or