"IsReadOnly" of GridViewDataColumn doesn't work.

1 Answer 279 Views
GridView
JIJIKO
Top achievements
Rank 1
Iron
JIJIKO asked on 05 Nov 2021, 07:47 AM

Hi (QwQ),

I met a problem that "IsReadOnly=true" of GridViewDataColumn doesn't work.

<telerik:GridViewDataColumn Header="IsChecked" DataMemberBinding="{Binding IsChecked}"
                        Style="{DynamicResource GridViewColumnStyle}" IsReadOnly="True">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox IsChecked="{Binding IsChecked}" Style="{DynamicResource CheckBoxStyle}"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
I can still edit the checkbox in column.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 09 Nov 2021, 03:35 PM

Hello Jijiko,

The IsReadOnly property would not work when a custom CellTemplate is defined because it is up to the developer to decide how to handle the elements, present in the template.

That said, to achieve the wanted behavior, you could either set the IsEnabled property to False or the IsHitTestVisible property to False, as an additional Setter in the CheckBoxStyle style. Both of these properties would prevent the user from modifying the checkboxes, however, the IsEnabled property will change the visuals of each box.

Alternatively, you could use our GridViewCheckBoxColumn column and set the IsReadOnly to True
<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsChecked}" IsReadOnly="True"/>

That said, I hope these suggestions work for your current scenario.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
JIJIKO
Top achievements
Rank 1
Iron
Answers by
Stenly
Telerik team
Share this question
or