DataGrid RowDetails not loading

4 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 04 May 2011 Link to this post

    Hello,

    I am trying to use two DomainDataSource controls to create a master\detail grid utilizing the RowDetails feature of the DataGrid.  I am following the demo shown here: http://demos.telerik.com/silverlight/#DomainDataSource/RowDetails

    I am finding that the DataGrid inside the RowDetails does not display the data, just an empty DataGrid.   To test the DomainDataSouce for the details, I created a second independant DataGrid that is also bound to the details DomainDataSource as shown in your demo: http://demos.telerik.com/silverlight/#DomainDataSource/MasterDetail 

    When I run the application, the master DataGrid (gvProducts) displays the products.  When I select a product, in the master DataGrid, the second DataGrid shows the corresponding detail information, however the DataGrid in the RowDetails section shows an empty DataGrid.

    Is there something that I am missing to get the DataGrid in the RowDetails secotion to bind correctly?  Here is my xaml.

    Thanks so much,

    Chris

    <UserControl x:Class="VMSPatchManager.MainPage"
        xmlns:web="clr-namespace:VMSPatchManager.Web"
        xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
      
      
      
        <Grid x:Name="LayoutRoot" Background="White">
      
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
      
            <telerik:RadDomainDataSource x:Name="ProductsDataSource" PageSize="15" AutoLoad="True" QueryName="GetTblProducts" LoadedData="ProductsDataSource_LoadedData">
                <telerik:RadDomainDataSource.DomainContext>
                    <web:VMSPatchesContext />
                </telerik:RadDomainDataSource.DomainContext>
            </telerik:RadDomainDataSource>
      
            <telerik:RadDomainDataSource x:Name="PatchesDataSource" PageSize="10" AutoLoad="True" QueryName="GetTblPatchesByProductID">
                <telerik:RadDomainDataSource.DomainContext>
                    <web:VMSPatchesContext />
                </telerik:RadDomainDataSource.DomainContext>
                <telerik:RadDomainDataSource.QueryParameters>
                    <telerik:QueryParameter ParameterName="ProductID" Value="{Binding SelectedItem.ProductID, ElementName=gvProducts}" />
                </telerik:RadDomainDataSource.QueryParameters>
            </telerik:RadDomainDataSource>
      
            <StackPanel Grid.Row="0" Orientation="Horizontal">
                <telerik:RadButton x:Name="submitChangesButton" Content="Submit Changes"
                                   Command="{Binding SubmitChangesCommand, ElementName=ProductsDataSource}" 
                                   CommandTarget="{Binding ElementName=ProductsDataSource}"/>
                <telerik:RadButton x:Name="rejectChangesButton" Content="Reject Changes" 
                                   Command="{Binding RejectChangesCommand, ElementName=ProductsDataSource}" 
                                   CommandTarget="{Binding ElementName=ProductsDataSource}"/>
            </StackPanel>
      
            <StackPanel  Grid.Row="1">
            <telerik:RadGridView x:Name="gvProducts" 
                                 ItemsSource="{Binding DataView, ElementName=ProductsDataSource}"
                                 IsBusy="{Binding IsBusy, ElementName=ProductsDataSource}"
                                 RowDetailsVisibilityMode="VisibleWhenSelected"
                                 ShowGroupPanel="False"
                                 CanUserFreezeColumns="False"
                                 RowIndicatorVisibility="Visible" 
                                 IsFilteringAllowed="False"
                                 CanUserSortColumns="False"
                                 AutoGenerateColumns="true" 
                                 IsReadOnly="True" SelectionChanged="gvProducts_SelectionChanged">
      
                  
                <!-- Row details-->
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>
                        <Border >
                            <telerik:RadGridView Margin="5"
                                                 ItemsSource="{Binding DataView, ElementName=PatchesDataSource}"
                                                 IsBusy="{Binding IsBusy,ElementName=PatchesDataSource}">
      
                                <telerik:RadGridView.Columns>                                                                
                                </telerik:RadGridView.Columns>                            
                            </telerik:RadGridView>
                        </Border>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>
            </telerik:RadGridView>
      
                <!-- seperate grid-->
            <telerik:RadGridView x:Name="gvPatches" 
                                 ItemsSource="{Binding DataView, ElementName=PatchesDataSource}"
                                 IsBusy="{Binding IsBusy, ElementName=PatchesDataSource}">
            </telerik:RadGridView>
            </StackPanel>
        </Grid>
    </UserControl>


  2. vk
    vk avatar
    46 posts
    Member since:
    Jul 2012

    Posted 05 May 2011 Link to this post

    Hi, Chris
    Declare RadDomainDataSource controls as resources:

    <Grid x:Name="LayoutRoot" Background="White"
        <Grid.RowDefinitions
            <RowDefinition Height="Auto" /> 
            <RowDefinition Height="*" /> 
        </Grid.RowDefinitions
      
      
      <Grid.Resources
        <!--DomainContext-->
        <web:VMSPatchesContext x:Key="DomainContext" /> 
       <!--ProductsDomainDataSource-->
        <telerik:RadDomainDataSource x:Key="ProductsDataSource"
    DomainContext="{StaticResource DomainContext}" 
    PageSize="15" 
    AutoLoad="True" 
    QueryName="GetTblProducts" 
    LoadedData="ProductsDataSource_LoadedData" /> 
     <!--PatchesDomainDataSource-->
        <telerik:RadDomainDataSource x:Key="PatchesDataSource"
    DomainContext="{StaticResource DomainContext}" 
    PageSize="10" 
    AutoLoad="True" 
    QueryName="GetTblPatchesByProductID"
               <telerik:RadDomainDataSource.QueryParameters
                <telerik:QueryParameter ParameterName="ProductID" 
    Value="{Binding SelectedItem.ProductID,ElementName=gvProducts}" /> 
                 </telerik:RadDomainDataSource.QueryParameters
         </telerik:RadDomainDataSource
        </Grid.Resources>
    </Grid>

    And change ItemsSource property of your product and patches grids like
    ItemsSource="{Binding DataView, Source={StaticResource ProductsDataSource}}"
    ItemsSource="{Binding DataView, Source={StaticResource PatchesDataSource}}"


  3. DevCraft banner
  4. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 05 May 2011 Link to this post

    That worked perfectly.  Thank you so much!

    Best regards,

    Chris
  5. Chaojie
    Chaojie avatar
    1 posts
    Member since:
    Feb 2012

    Posted 07 Mar 2012 Link to this post

    That's works fine. i am a newbie to silverlight&telerik, i am curious about the reason to declare domain data source as Resources? why this works good? any related document?
    thx
Back to Top