RadGridView as DataFormDataField

4 posts, 0 answers
  1. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 18 Sep 2013 Link to this post

    I'm using a RadGridView as the data template for a DataFormDataField to display child data. I can populate the control but adding and editing items in the table doesn't enable the commit (OK) button of the parent RadDataForm. 

    <telerik:DataFormDataField Label="Logins:"
                                LabelPosition="Above">
        <telerik:DataFormDataField.ContentTemplate>
            <DataTemplate>
                <telerik:RadGridView x:Name="LoginsGrid"
                                        ShowGroupPanel="False"
                                        RowIndicatorVisibility="Collapsed"
                                        AutoGenerateColumns="False"
                                        ItemsSource="{Binding Logins, Mode=TwoWay}"
                                        Margin="0,10,0,0"
                                        IsFilteringAllowed="False"
                                        Height="250"
                                        MaxWidth="405"
                                        ShowInsertRow="True">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewComboBoxColumn Header="Login Type"
                                                        DataMemberBinding="{Binding LoginType, Mode=TwoWay}"
                                                        ItemsSource="{Binding ElementName=LayoutRoot, Path=DataContext.LoginTypes}"
                                                        SelectedValueMemberPath="ID"
                                                        DisplayMemberPath="Value"
                                                        MinWidth="120"/>
                        <telerik:GridViewDataColumn Header="Name"
                                                    DataMemberBinding="{Binding LoginName, Mode=TwoWay}"
                                                    MinWidth="120"/>
                        <telerik:GridViewDataColumn Header="Password"
                                                    DataMemberBinding="{Binding LoginPassword, Mode=TwoWay}"
                                                    MinWidth="120"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </DataTemplate>
        </telerik:DataFormDataField.ContentTemplate>
    </telerik:DataFormDataField>

    I've tried setting the DataMemberBinding of the data field, but that messes up the grid.

    <telerik:DataFormDataField Label="Logins:"
                                LabelPosition="Above"
                                DataMemberBinding="{Binding Logins, Mode=TwoWay}">
        <telerik:DataFormDataField.ContentTemplate>
            <DataTemplate>
                <telerik:RadGridView x:Name="LoginsGrid"
                                        ShowGroupPanel="False"
                                        RowIndicatorVisibility="Collapsed"
                                        AutoGenerateColumns="False"
                                        ItemsSource="{Binding}"
                                        Margin="0,10,0,0"
                                        IsFilteringAllowed="False"
                                        Height="250"
                                        MaxWidth="405"
                                        ShowInsertRow="True">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewComboBoxColumn Header="Login Type"
                                                        DataMemberBinding="{Binding LoginType, Mode=TwoWay}"
                                                        ItemsSource="{Binding ElementName=LayoutRoot, Path=DataContext.LoginTypes}"
                                                        SelectedValueMemberPath="ID"
                                                        DisplayMemberPath="Value"
                                                        MinWidth="120"/>
                        <telerik:GridViewDataColumn Header="Name"
                                                    DataMemberBinding="{Binding LoginName, Mode=TwoWay}"
                                                    MinWidth="120"/>
                        <telerik:GridViewDataColumn Header="Password"
                                                    DataMemberBinding="{Binding LoginPassword, Mode=TwoWay}"
                                                    MinWidth="120"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </DataTemplate>
        </telerik:DataFormDataField.ContentTemplate>
    </telerik:DataFormDataField>

    What's the correct way to get the behavior I'm looking for; i.e., changes to the child grid triggering the commit button?

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 19 Sep 2013 Link to this post

    Hello Art,

     What is the value of RadDataForm's AutoCommit property that you have set?

    Regards,
    Ivan Ivanov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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. DevCraft banner
  4. Art Kedzierski
    Art Kedzierski avatar
    107 posts
    Member since:
    Nov 2009

    Posted 19 Sep 2013 Link to this post

    False. Here is the form:

    <telerik:RadDataForm x:Name="_equipmentDetail"
                         ItemsSource="{Binding Equipment}"
                         CurrentItem="{Binding SelectedEquipment, Mode=TwoWay}"
                         Grid.Column="1"
                         Grid.Row="1"
                         AutoCommit="False"
                         AutoGenerateFields="False"
                         EditTemplate="{StaticResource EquipmentEditItem}"
                         NewItemTemplate="{StaticResource EquipmentEditItem}"
                         ReadOnlyTemplate="{StaticResource EquipmentReadItem}"
                         Margin="-1,0,0,0"
                         CommandButtonsVisibility="Add, Edit, Navigation, Commit, Cancel">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="EditEnded">
                <ei:CallMethodAction TargetObject="{Binding}"
                                     MethodName="Device_EditEnded"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>
    </telerik:RadDataForm>
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 19 Sep 2013 Link to this post

    Hi,

     The AutoCommit logic relies on INotifyPropertyChanged. Adding an item to a collection property does not change the property value. Moreover, this feature is supported only for properly bound DataFields. For such custom scenarios, your only option is to use AutoCommit=true.

    Regards,
    Ivan Ivanov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    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