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

Value typed in DataFormDataField are not save

2 Answers 78 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 21 Sep 2011, 02:56 PM
Hello,
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">
 
    <UserControl.Resources>
        <DataTemplate x:Key="EditEmployeeTemplate">
            <StackPanel>
                <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}" />
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <StackPanel>
        <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" />
            </StackPanel>
    </StackPanel>
             
</UserControl>

Thank you.
Best regards,
Alexander

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 26 Sep 2011, 03:49 PM
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.

Regards,
Pavel Pavlov
the Telerik team

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

0
Alexander
Top achievements
Rank 1
answered on 27 Sep 2011, 01:39 PM
Hi,
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));
            else
                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);
 
            OnCloseEditEmployee();
            TryClose();
        }

Hope this will help.

Best regards,
Alexander
Tags
DataForm
Asked by
Alexander
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or