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

RadDataForm - Custom Template not working with Cancel?

3 Answers 163 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 13 Nov 2013, 03:27 PM
I have a RadDataForm bound to a single DataRowView of a DataTable.  If I allow the form to auto-generate the editor fields, the "Cancel" function works as advertised.  That is, I can edit any number of the fields, press Cancel, and their original values are returned prior the the form shifting back to ReadOnly mode.

However, if I supply a custom template for the same DataRowView, when I edit some data and press Cancel, the original values are not put back into the editor fields.  The form is placed back in ReadOnly mode (as expected), but the modified values are still there.

How can I get a custom template to play nicely with the Cancel function?  I see no mention of this anomaly in the docs or on the forums.

Jeff

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 15 Nov 2013, 11:03 AM
Hello Jeff,

The DataRowView implements the IEditableObject interface: http://msdn.microsoft.com/en-us/library/system.data.datarowview(v=vs.110).aspx. Does your custom template implement it?

Please refer to our online documentation here.
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jeff
Top achievements
Rank 1
answered on 15 Nov 2013, 02:12 PM
Sorry, I guess I don't follow.  I simply created a custom template for my DataRowView, much as described in your docs here:

http://www.telerik.com/help/wpf/raddataform-customized-fields.html

That test template looks like this:

<!--<Grid.Resources>
    <DataTemplate x:Key="MyTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <telerik:DataFormDataField DataMemberBinding="{Binding Nest, Mode=TwoWay}"
                                       Label="Nest ID" />
            <telerik:DataFormDataField Grid.Column="1"
                                       DataMemberBinding="{Binding Mater, Mode=TwoWay}"
                                       Label="Material" />
            <telerik:DataFormDataField Grid.Row="1"
                                       Grid.Column="1"
                                       DataMemberBinding="{Binding MaxTime, Mode=TwoWay}"
                                       Label="Max Time" />
        </Grid>
    </DataTemplate>
</Grid.Resources>-->

Then, I wired the new template to my DataForm - again, as described in your documentation.  That looks like this:

<telerik:RadDataForm x:Name="dataForm"
       HorizontalAlignment="Stretch"
       VerticalAlignment="Stretch"
       AutoGeneratingField="dataForm_AutoGeneratingField"
       CommandButtonsVisibility="All"
       CommandProvider="{StaticResource CustomProvider}"
       EditEnded="dataForm_EditEnded"
       IsEnabled="{Binding IsEnabled}"
       ItemsSource="{Binding TableData}"
       NewItemTemplate="{StaticResource MyTemplate}"
       ReadOnlyTemplate="{StaticResource MyTemplate}"
       EditTemplate="{StaticResource MyTemplate}"
       AutoGenerateFields="False" />

So, I really just linked a few fields of the bound DataRowView to a custom template and activated the template.  Since the underlying data is still the DataRowView, why would I need to implement the IEditableObject interface?

Jeff
0
Dimitrina
Telerik team
answered on 19 Nov 2013, 12:47 PM
Hello,

The reason for this behavior is that you assign the same template(MyTemplate) as ReadOnlyTemplate and as EditTemplate.
Please note that you should assign different ones as these two templates.
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or