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

Load on Demand WCF RIA services

2 Answers 61 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
CD
Top achievements
Rank 1
CD asked on 14 Mar 2011, 09:12 PM
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 Answers, 1 is accepted

Sort by
0
CD
Top achievements
Rank 1
answered on 15 Mar 2011, 06:42 PM
I believe I found the issue, the domain service did not support the relationship.
0
Christine
Top achievements
Rank 1
answered on 29 Mar 2011, 03:44 PM
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!
Tags
TreeView
Asked by
CD
Top achievements
Rank 1
Answers by
CD
Top achievements
Rank 1
Christine
Top achievements
Rank 1
Share this question
or