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

Child table ignoring relationship

1 Answer 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 20 Dec 2011, 10:12 AM
Hi,
I have a single data context and within my edmx model I have 2 tables.

Table 1 (Parent Table) (Loads grdSAPBatches)
AUFNR    Primary key
BATCH_Type
ENGINE_TYPE
START_DATE
START_TIME
PROGRAMMED_QTY

Table 2 (Child Table) (Loads grdSAPComponents)

 

AUFNR    FK1
TAG_POSITION FK2
COMPONENT
MESSAGE

I have a Grid and I have set as follows following the sample to show Table 1 data and on expand of row I would want to see filtered table 2 data with the relationship being AUFNR - but the child table seems to be ignoring the relationship I specified in xaml and just loading all the table 2 data?

I have changed self reference to False and True and it makes no difference....

The VB I am using to load the data is as follows

 

Dim vwSAPBatchesViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("TblSAP_BatchesViewSource"), System.Windows.Data.CollectionViewSource)

vwSAPBatchesViewSource.Source = context.fnGetSapBatches

Child Table

Dim vwSAPComponentsViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("TblSAP_ComponentsViewSource"), System.Windows.Data.CollectionViewSource)

vwSAPComponentsViewSource.Source = context.fnGetSapComponents

The bold items are the imports in edmx to SP's in sql server - neither fn's take parameters as I assumed the grid would filter the child data automatically once the relationship was set?

 

<Grid Margin="3" Grid.Column="1" Name="GridSAP">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <TextBlock x:Name="textBlock_Copy" TextWrapping="Wrap" Text="SAP Staging Table" FontFamily="Segoe UI" FontSize="13.333" VerticalAlignment="Center" FontStyle="Italic" Foreground="#FF969696" HorizontalAlignment="Center"/>
    <StackPanel x:Name="stkStaging" Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Top"/>
    <telerik:RadGridView  ItemsSource="{Binding}" AutoGenerateColumns="False" x:Name="grdSAPBatches" DataContext="{StaticResource TblSAP_BatchesViewSource}" IsReadOnly="True" ShowGroupPanel="False" AlternateRowBackground="{x:Null}" Background="{x:Null}" ColumnBackground="#FF1E1E1E" Foreground="White" HorizontalGridLinesBrush="#FF323232" VerticalGridLinesBrush="#FF323232" RowIndicatorVisibility="Collapsed" BorderBrush="#FF0E0E0E" IsFilteringAllowed="False" CanUserFreezeColumns="False" ScrollViewer.CanContentScroll="True" VerticalAlignment="Top" d:LayoutOverrides="Width" Grid.Row="1" DataLoadMode="Asynchronous" HorizontalAlignment="Right" Style="{DynamicResource RadGridViewStyle_EPMS}"  GroupRowStyle="{DynamicResource GridViewGroupRowStyle_EPMS}" GroupPanelBackground="#FF0E0E0E">
        <telerik:RadGridView.ChildTableDefinitions>
            <telerik:GridViewTableDefinition>
                <telerik:GridViewTableDefinition.Relation>
                    <telerik:TableRelation IsSelfReference="False">
                        <telerik:TableRelation.FieldNames>
                            <telerik:FieldDescriptorNamePair ParentFieldDescriptorName="AUFNR" ChildFieldDescriptorName="AUFNR"/>
                        </telerik:TableRelation.FieldNames>
                    </telerik:TableRelation>
                </telerik:GridViewTableDefinition.Relation>
            </telerik:GridViewTableDefinition>
        </telerik:RadGridView.ChildTableDefinitions>
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn UniqueName="AUFNR" DataMemberBinding="{Binding AUFNR}" Header="Batch No." IsGroupable="False" IsFilterable="False"/>
            <telerik:GridViewDataColumn UniqueName="BATCH_TYPE" DataMemberBinding="{Binding BATCH_TYPE}" Header="Batch Type" IsGroupable="False" IsFilterable="False"/>
            <telerik:GridViewDataColumn UniqueName="ENGINE_TYPE" DataMemberBinding="{Binding ENGINE_TYPE}" Header="Part No." IsGroupable="False" IsFilterable="False"/>
            <telerik:GridViewDataColumn UniqueName="START_DATE" DataMemberBinding="{Binding START_DATE}" Header="Sched. Date" IsGroupable="False" IsFilterable="False"/>
            <telerik:GridViewDataColumn UniqueName="START_TIME" DataMemberBinding="{Binding START_TIME}" Header="Sched. Time" IsGroupable="False" IsFilterable="False"/>
            <telerik:GridViewDataColumn UniqueName="PROGRAMMED_QTY" DataMemberBinding="{Binding PROGRAMMED_QTY}" Header="Batch Qty" IsGroupable="False" IsFilterable="False"/>
        </telerik:RadGridView.Columns>
        <telerik:RadGridView.HierarchyChildTemplate>
            <DataTemplate>
                <telerik:RadGridView DataContext="{StaticResource TblSAP_ComponentsViewSource}" AutoGenerateColumns="False"  x:Name="grdSAPComponents" ItemsSource="{Binding}" ShowGroupPanel="False" AlternateRowBackground="{x:Null}" Background="{x:Null}" ColumnBackground="#FF1E1E1E" Foreground="White" HorizontalGridLinesBrush="#FF323232" VerticalGridLinesBrush="#FF323232" RowIndicatorVisibility="Collapsed" BorderBrush="#FF0E0E0E" IsFilteringAllowed="True" CanUserFreezeColumns="False" ScrollViewer.CanContentScroll="True" VerticalAlignment="Top" d:LayoutOverrides="Width" Grid.Row="1" DataLoadMode="Asynchronous" HorizontalAlignment="Right" Style="{DynamicResource RadGridViewStyle_EPMS}">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn UniqueName="AUFNR" DataMemberBinding="{Binding AUFNR}" Header="Batch No." IsGroupable="True" IsFilterable="True"/>
                        <telerik:GridViewDataColumn UniqueName="TAG_POSITION" DataMemberBinding="{Binding TAG_POSITION}" Header="Tag Position" IsGroupable="True" IsFilterable="True"/>
                        <telerik:GridViewDataColumn UniqueName="COMPONENT" DataMemberBinding="{Binding COMPONENT}" Header="Component" IsGroupable="True" IsFilterable="True"/>
                        <telerik:GridViewDataColumn UniqueName="HMI_MESSAGE" DataMemberBinding="{Binding HMI_MESSAGE}" Header="HMI Message" IsGroupable="True" IsFilterable="True"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </DataTemplate>
        </telerik:RadGridView.HierarchyChildTemplate>
          
    </telerik:RadGridView>
</Grid>


Any help much appreciated...

1 Answer, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 20 Dec 2011, 02:51 PM
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Share this question
or