Cancel delete and edit the current record

4 posts, 1 answers
  1. Harald
    Harald avatar
    76 posts
    Member since:
    Oct 2013

    Posted 18 Feb 2018 Link to this post

    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?

     

     

  2. Harald
    Harald avatar
    76 posts
    Member since:
    Oct 2013

    Posted 19 Feb 2018 Link to this post

    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>

     

  3. Answer
    Dinko
    Admin
    Dinko avatar
    951 posts

    Posted 21 Feb 2018 Link to this post

    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.
  4. Harald
    Harald avatar
    76 posts
    Member since:
    Oct 2013

    Posted 26 Feb 2018 in reply to Dinko Link to this post

    Thanks. 
Back to Top