BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
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; }
}
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>
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
Got it, thanks
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.