Value typed in DataFormDataField are not save

3 posts, 0 answers
  1. Alexander
    Alexander avatar
    16 posts
    Member since:
    Dec 2010

    Posted 21 Sep 2011 Link to this post

    In our application we have an edit dialog that uses DataForm which contains DataFormDataFields which are binded to different properties from view model. Also in dialog are used two RadButtons for save edited data and cancel edit. This buttons are set to response on "Esc" and "Enter" keys. When user press "Enter" key, the new data modifications are save. The problem is that the last edited DataFormDataField (the last field in which was modified a value) does not save the modified value. Below is the code we use:
    <UserControl x:Class="MyApplication.MyView"
        Height="400" Width="500">
            <DataTemplate x:Key="EditEmployeeTemplate">
                    <telerik:DataFormDataField Label="First name" DataMemberBinding="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=Default}" />
                    <telerik:DataFormDataField Label="Last name" DataMemberBinding="{Binding LastName, Mode=TwoWay, UpdateSourceTrigger=Default}" />
                    <telerik:DataFormDataField Label="Middle name" DataMemberBinding="{Binding MiddleName, Mode=TwoWay, UpdateSourceTrigger=Default}" />
                    <telerik:DataFormDataField Label="Nickname" DataMemberBinding="{Binding Contact.Nickname, Mode=TwoWay, UpdateSourceTrigger=Default}" />
                          <telerik:DataFormDateField Label="Birthday" DataMemberBinding="{Binding Contact.BirthDay, Mode=TwoWay, UpdateSourceTrigger=Default}" />
                    <telerik:DataFormDataField Label="Language" DataMemberBinding="{Binding Contact.Language, Mode=TwoWay, UpdateSourceTrigger=Default}" />
            <telerik:RadDataForm CurrentItem="{Binding Employee}" EditTemplate="{StaticResource EditEmployeeTemplate}"
                                         BorderBrush="Transparent" CommandButtonsVisibility="None"
                                         AutoGenerateFields="False" x:Name="Form" AutoEdit="True" />
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                    <telerik:RadButton Content="Save" Width="75" Height="23" telerik:RadWindow.ResponseButton="Accept"
                                           Margin="0,0,4,0" Micro:Message.Attach="SaveAction()" />
                    <telerik:RadButton Content="Cancel" Width="75" Height="23" Micro:Message.Attach="CancelAction()"
                                           telerik:RadWindow.ResponseButton="Cancel" />

    Thank you.
    Best regards,
  2. Pavel Pavlov
    Pavel Pavlov avatar
    2039 posts

    Posted 26 Sep 2011 Link to this post

    Hi Alexander,

    I erroneous behavior here. Can you please paste me the code you execute on the Accept button .

    Meanwhile as a workaround I may suggest to use the integrated buttons in RadDataForm for Cancel/Commit actions.

    Pavel Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Alexander
    Alexander avatar
    16 posts
    Member since:
    Dec 2010

    Posted 27 Sep 2011 Link to this post

    In our application we are using MVVM patter so the method that is called on Accept button is in VM class and it looks as below:
    public IEnumerable<IResult> SaveAction()
                ServiceCommand<IEditCrmEntityService> result;
                if (isNewEmployee)
                    result = builder.Command(s => s.AddEmployee(EntityId, Employee));
                    result = builder.Command(s => s.UpdateEmployee(EntityId, Employee));
                yield return result;
                if (result.Failed)
                    TelerikWindowManager.Alert("Fail", "Fail to update or create contact. \n" + result.Exception);

    Hope this will help.

    Best regards,
Back to Top