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

Cancel delete and edit the current record

3 Answers 576 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Harald
Top achievements
Rank 2
Harald asked on 18 Feb 2018, 04:43 PM

I want to cancel the delete event and not delete the current record. I just want to edit the current record and set the property "IsActive = false". 

1.private void MyDataForm_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e)
2.        {
3.            Person currentPerson = this.MyDataForm.CurrentItem as Person;
4.            currentPerson.IsActive = true;
5.            e.Cancel = true;
6.        }

This code does not work. How can I implement the function?

 

 

3 Answers, 1 is accepted

Sort by
0
Harald
Top achievements
Rank 2
answered on 19 Feb 2018, 08:25 PM

The record changes in the background, but the RadDataForm and RadGridView still display the previous state.

<telerik:RadGridView x:Name="MyGridView" Grid.Column="0" Grid.Row="1" IsSynchronizedWithCurrentItem="True" ShowSearchPanel="False"
                                ItemsSource="{DynamicResource peopleViewSource}"
                                SelectedCellsChanged="MyGridView_SelectedCellsChanged"
                                SelectedCellsChanging="MyGridView_SelectedCellsChanging"
                                SelectionChanged="MyGridView_SelectionChanged"
                                SelectionChanging="MyGridView_SelectionChanging" IsReadOnly="True" SearchPanelVisibilityChanged="MyGridView_SearchPanelVisibilityChanged" AutoGeneratingColumn="MyGridView_AutoGeneratingColumn"/>
       <telerik:RadDataForm x:Name="MyDataForm" Grid.Column="0" Grid.Row="3" Header="Detailansicht" LabelPosition="Above"
                            CurrentItem="{Binding ElementName=MyGridView, Path=CurrentItem, Mode=TwoWay, NotifyOnTargetUpdated=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                            ItemsSource="{Binding Items, ElementName=MyGridView}"
                            AddedNewItem="MyDataForm_AddedNewItem"
                            AddingNewItem="MyDataForm_AddingNewItem"
                            BeginningEdit="MyDataForm_BeginningEdit"
                            DeletedItem="MyDataForm_DeletedItem"
                            DeletingItem="MyDataForm_DeletingItem"
                            EditEnded="MyDataForm_EditEnded"
                            EditEnding="MyDataForm_EditEnding"
                            ValidatingItem="MyDataForm_ValidatingItem"
                            ValidationSummaryVisibility="Collapsed"
                            CurrentItemChanged="MyDataForm_CurrentItemChanged"
                            AutoGeneratingField="MyDataForm_AutoGeneratingField">
       </telerik:RadDataForm>

 

0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 21 Feb 2018, 12:50 PM
Hello Harald,

I am not sure that I have fully understood your scenario. To cancel the delete functionality you can set the Cancel property from the event (DeletingItem) arguments to true. As you have already done that. Can you elaborate more on your scenario? What is not working? 

I have created sample project based on the provided code snippets. When I press the delete button of the RadDataForm the IsActive property of the business item will be set to false but will not be deleted. I have found this property to the IsEnabled property of the GridViewRow using implicit style.

Give this project a try and let me know if this is similar to the behavior which you are trying to achieve.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Harald
Top achievements
Rank 2
answered on 26 Feb 2018, 10:28 AM
Thanks. 
Tags
DataForm
Asked by
Harald
Top achievements
Rank 2
Answers by
Harald
Top achievements
Rank 2
Dinko | Tech Support Engineer
Telerik team
Share this question
or