RadDataForm - Custom Template not working with Cancel?

4 posts, 0 answers
  1. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 13 Nov 2013 Link to this post

    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
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Nov 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeff
    Jeff avatar
    39 posts
    Member since:
    Jun 2013

    Posted 15 Nov 2013 Link to this post

    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
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Nov 2013 Link to this post

    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 >>
Back to Top