We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridCheckBoxColumn is disabled

I have an sfDatagrid containing a check box column, which is displaying as grey (disabled) and is not accepting input. The column is not readonly, and the underlying boolean in the view model is not readonly. What do I have to do to make the field editable?


            <syncfusion:SfDataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                           ItemsSource="{Binding Changes}"
                    AutoGenerateColumns="False" ColumnSizer="Auto" AllowSorting="False" AllowResizingColumns="True"
                    AllowDraggingRows="True" AllowDrop="True">
                <syncfusion:SfDataGrid.Columns>
                    <syncfusion:GridCheckBoxColumn HeaderText="" MappingName="Selected" IsReadOnly="False"/>
                    <syncfusion:GridTextColumn HeaderText="Description" MappingName="Description"/>
                </syncfusion:SfDataGrid.Columns>

            </syncfusion:SfDataGrid>

public class EntrantChange : ViewModelBase

{

      public bool Selected { get; set; }

      public string Description { get; }

}


4 Replies

RU Russell March 13, 2023 03:14 AM UTC

OK, so I've added another column using a DataTemplate to display the checkbox, and that works fine. Go figure.


<syncfusion:SfDataGrid.Columns>
<syncfusion:GridCheckBoxColumn HeaderText="X" MappingName="Selected" Width="54" IsReadOnly="False"/>
<syncfusion:GridTextColumn HeaderText="Y" MappingName="Selected" Width="54">
<syncfusion:GridTextColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Selected}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</DataTemplate>
</syncfusion:GridTextColumn.CellTemplate>
</syncfusion:GridTextColumn>
</syncfusion:SfDataGrid.Columns>




SJ Sathiyathanam Jeyakumar Syncfusion Team March 13, 2023 12:51 PM UTC

Hi Russell,

To enable editing for columns in the DataGrid, make sure to set the AllowEditing property to true. If this property is not enabled, you will not be able to edit the checkbox. Additionally, if your underlying property is of boolean type, you can directly use the GridCheckBoxColumn instead of manually adding a checkbox to a CellTemplate. The GridCheckBoxColumn will take care of displaying the checkbox and updating the value of the underlying property automatically.

UG Link : https://help.syncfusion.com/wpf/datagrid/editing

Let us know if you need any further assistance on this.


Regards,

Sathiyathanam



RU Russell March 13, 2023 11:35 PM UTC

Got it, thanks



SJ Sathiyathanam Jeyakumar Syncfusion Team March 14, 2023 05:45 PM UTC

Russell,

We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out. 


Loader.
Live Chat Icon For mobile
Up arrow icon