This is a migrated thread and some comments may be shown as answers.

GridViewCheckBoxColumn CellTemplate Problem

1 Answer 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ss
Top achievements
Rank 1
ss asked on 14 Nov 2019, 03:16 PM
I want to display checkbox with text next to each other. But the solution below does not work. Only Checkbox is displayed. What is wrong?
 
<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnlyBinding="{Binding Unavailable}" EditTriggers="CellClick"  Header="Check" Width="Auto">
                                <telerik:GridViewCheckBoxColumn.CellTemplate>
                                    <DataTemplate DataType="{x:Type views:ItemList}">
                                        <Grid>
                                            <CheckBox IsChecked="{Binding IsChecked}" IsEnabled="{Binding Unavailable, Converter={StaticResource InverseBooleanConverter}}" Command="{.....}, Path=Data}"
                                                      CommandParameter="{...}">
                                                <CheckBox.Content>
                                                    <TextBlock Text="{Binding Status, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextAlignment="Right"></TextBlock>
                                                </CheckBox.Content>
 
                                            </CheckBox>
 
                                        </Grid>
 
                                    </DataTemplate>

 

....

1 Answer, 1 is accepted

Sort by
0
Dimitar Dinev
Telerik team
answered on 18 Nov 2019, 03:17 PM

Hi,

Thank you for the code snippet.

The GridViewCheckBoxColumn doesn't support the CellTemplate attached property, since its expected to contain only a CheckBox.

One way to achieve the desired behavior is to replace the GridViewCheckBoxColumn with GridViewDataColumn and define the cell template you pointed.

Another approach would be to create a custom GridViewCheckBoxColumn and override its CreateCellElement and CreateCellEditElement methods. You can find more information in the Create Custom Column Editor article.

Attached, you can find a sample project which demonstrates the first approach. Please, review it and let me know if it delivered the desired result.

Regards,
Dimitar Dinev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
ss
Top achievements
Rank 1
Answers by
Dimitar Dinev
Telerik team
Share this question
or