Load on Demand WCF RIA services

3 posts, 0 answers
  1. CD
    CD avatar
    14 posts
    Member since:
    Mar 2011

    Posted 14 Mar 2011 Link to this post

    Hello

    I am studying your treeviewloadondemandriaservices.zip sample project. I would like to add another level to the tree so it would be
    Customers --> Orders --> Order_Details --> Product

    No luck getting Products to load, perhaps it is my data templates.

    Part of the xaml for the view
    <navigation:Page.Resources>
        <DataTemplate x:Key="DetailTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="ProductID: "/>
                <TextBlock Text="{Binding ProductID}"/>
            </StackPanel>
        </DataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="ProductTemplate"
            ItemsSource="{Binding Products}" ItemTemplate="{StaticResource DetailTemplate}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Order Detail Row [Quantity Field]: "/>
                <TextBlock Text="{Binding Quantity}"/>
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="OrderTemplate" ItemsSource="{Binding Order_Details}" 
        ItemTemplate="{StaticResource ProductTemplate}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="OrderID: "/>
                <TextBlock Text="{Binding OrderID}"/>
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Name="Root" x:Key="CustomerTemplate" ItemsSource="{Binding Orders}" 
        ItemTemplate="{StaticResource OrderTemplate}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="CustomerID: "/>
                <TextBlock Text="{Binding CustomerID}"/>
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
    </navigation:Page.Resources>



    Part of the code-behind for the view:

    private void myTreeView_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        RadTreeViewItem clickedItem = e.OriginalSource as RadTreeViewItem;
        switch (clickedItem.Item.GetType().Name)
        {
            case "Customer":
                _Context.Load(_Context.GetOrdersByCustomerIDQuery((clickedItem.Item as Customer).CustomerID));
                break;
            case "Order":
                _Context.Load(_Context.GetOrderDetailsQuery((clickedItem.Item as Order).OrderID));
                break;
            case "Order_Detail":
                //Get the Product info for the Order Detail record
                _Context.Load(_Context.GetProductsByOrderDetailQuery((clickedItem.Item as Order_Detail).OrderID, (clickedItem.Item as Order_Detail).ProductID));
                break;
            default:
                break;
        }
    }
    private void myTreeView_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
    {
        if (e.PreparedItem.Item is Product)
        {
            e.PreparedItem.IsLoadOnDemandEnabled = false;
        }
    }

    When I expand the order detail node, the context load is hit, but the order detail node does not expand, the loading arrow just spins.

    Thanks in advance!
  2. CD
    CD avatar
    14 posts
    Member since:
    Mar 2011

    Posted 15 Mar 2011 Link to this post

    I believe I found the issue, the domain service did not support the relationship.
  3. DevCraft banner
  4. Christine
    Christine avatar
    3 posts
    Member since:
    Jun 2009

    Posted 29 Mar 2011 Link to this post

    I'm dealing with this same issue right now.  Can you tell me how you fixed this?  How did you correct the domain service so it did support the relationship?
    Thanks in advance!
Back to Top