AllowEditing with binding to combobox selecteditem
I am trying to change the AllowEditing property using the selecteditem of the combobox.
<Syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding Steps}"
EditTrigger="OnTap" VerticalAlignment="Stretch" AutoGenerateColumns="False" AddNewRowPosition="Bottom">
<Syncfusion:SfDataGrid.Columns>
<Syncfusion:GridComboBoxColumn HeaderText="Action" ItemsSource="{Binding Path=ActionList}" DisplayMemberPath="Name" MappingName="SelectedAction" AllowEditing="True"/>
<Syncfusion:GridTextColumn HeaderText="Origine" MappingName="Origin" AllowEditing="{Binding Path=SelectedAction.OriginEditable}" Width="150"/>
<Syncfusion:GridTextColumn HeaderText="Destination" MappingName="Destination" AllowEditing="{Binding Path=SelectedAction.DestinationEditable }" Width="150"/>
<Syncfusion:GridTextColumn x:Name="origin" HeaderText="OriginEditable" MappingName="SelectedAction.OriginEditable" Width="50"/>
<Syncfusion:GridTextColumn HeaderText="DestinationEditable" MappingName="SelectedAction.DestinationEditable" Width="50"/>
</Syncfusion:SfDataGrid.Columns>
</Syncfusion:SfDataGrid>For example when the property SelectedAction.OriginEditable is true i want the cell displaying the origin to be editable and when false the cell should not be editable.
For any reason my binding for AllowEditing is not working.
Attachment: DatagridGridTextColumnReadonly_56b65d8e.zip
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
MA
Mohanram Anbukkarasu
Syncfusion Team
September 28, 2021 01:44 PM UTC
Hi Benjamin,
Thanks for contacting Syncfusion support.
We have checked the provided sample and we are little unclear about your requirement. We suspect that your requirement is to enable/disable editing for the Origin column based on the value of the SelectedAction.DestinationEditable property in the same row. You have to make use of the SfDataGrid.CurrentCellBeginEdit event to achieve this requirement as shown below.
Code example :
|
private void DataGrid_CurrentCellBeginEdit(object sender, Syncfusion.UI.Xaml.Grid.CurrentCellBeginEditEventArgs e)
{
if(e.Column.MappingName == "Origin")
{
var record = this.dataGrid.RowGenerator.Items.FirstOrDefault(x => x.RowIndex == e.RowColumnIndex.RowIndex).RowData as StepViewModel;
e.Cancel = !record.SelectedAction.DestinationEditable;
}
} |
Sample link : https://www.syncfusion.com/downloads/support/forum/169197/ze/DatagridGridTextColumnReadonly_Modified-1850447875
Please let us know if you require any other assistance from us.
Regards,
Mohanram A.
Marked as answer
BM
Benjamin Moiroud
September 28, 2021 02:03 PM UTC
Yes this is what i need !
Thank you !
MA
Mohanram Anbukkarasu
Syncfusion Team
September 28, 2021 02:05 PM UTC
Hi Benjamin,
Thanks for the update.
We are glad to know that the provided solution worked at your end. Please let us know if you require any other assistance from us.
Regards,
Mohanram A.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
BM Benjamin Moiroud
- Sep 27, 2021 08:34 PM UTC
- Sep 28, 2021 02:05 PM UTC