LoadOnDemad via WCF Not Loading

2 posts, 0 answers
  1. Joe
    Joe avatar
    4 posts
    Member since:
    Jun 2011

    Posted 20 Jul 2011 Link to this post


        New customer evaluating controls and I have a problem getting the RadTreeView to Load on Demand.  I tried following the examples in the Help section and follow some of the tips from the forums with no luck.

        I have a RadTreeView which should load on demand by making calls to a WCF service, debugging the app the calls are made properly and data is returned.  

        When clicking on a Node to select and then expanding the node by clicking the little arrow the TreeView will load properly.  But when just trying to click on the error to expand the node, the call to the service is made and data is returned, BUT the Ajax indicator is displayed and just sits there and spins and no nodes are ever added to the grid.

        Any help would be greatly appreciated.  Here is the XAML: 

    <UserControl x:Class="SilverLightRemitFlow.MainPage"
            mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
            <DataTemplate x:Key="OrdersTemplate">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="OrderID : " />
                    <TextBlock Text="{Binding OrderID}" />
            <telerik:HierarchicalDataTemplate x:Key="tplPayers" ItemsSource="{Binding XXX}" ItemTemplate="{StaticResource OrdersTemplate}">
                <TextBlock Text="{Binding PayerName}" />
            <telerik:HierarchicalDataTemplate x:Key="tplFacilities" ItemsSource="{Binding PayerNode}" ItemTemplate="{StaticResource tplPayers}">
                <TextBlock Text="{Binding FacilityName}" />
            <telerik:HierarchicalDataTemplate x:Key="tplHospitalSystem" ItemsSource="{Binding Facility}" ItemTemplate="{StaticResource tplFacilities}"  >
                <TextBlock Text="{Binding SystemName}" />
        <Grid x:Name="LayoutRoot">
                <RowDefinition />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            <sdk:GridSplitter x:Name="grsplSplitter" Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center" Background="Aqua" Width="5">
            <TextBlock Text="Load on Demand" Margin="8"/>
            <telerik:RadTreeView Height="554" HorizontalAlignment="Left" Margin="12,34,0,0" Name="radTree" VerticalAlignment="Top" Width="314" Background="Gainsboro"
                                 IsLoadOnDemandEnabled="True" IsExpandOnSingleClickEnabled="False" ItemTemplate="{StaticResource tplHospitalSystem}"
                                 ItemClick="radTree_LoadOnDemand" Expanded="radTree_Expanded">

    And The Code Behind:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using SilverLightRemitFlow.RemitFlow.WebServiceSite;
    using Telerik.Windows.Controls;
    using System.Collections.ObjectModel;
    namespace SilverLightRemitFlow {
        public partial class MainPage : UserControl {
            public MainPage() {
                this.radTree.LoadOnDemand += new EventHandler<Telerik.Windows.RadRoutedEventArgs>(radTree_LoadOnDemand);
                this.radTree.ItemPrepared += new EventHandler<RadTreeViewItemPreparedEventArgs>(radTree_ItemPrepared);
                Loaded += MainPage_Loaded;
            public void MainPage_Loaded(object sender, RoutedEventArgs e) {
            public void radTree_ItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e) {
                RadTreeViewItem item = e.PreparedItem;
                if (item.Item is EobDetail) {
                    //item.IsLoadOnDemandEnabled = false;
            private RadTreeViewItem currentItem;
            public void radTree_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e) {
                RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
                currentItem = item;
                HospitalSystem h = currentItem.Item as HospitalSystem;
                if (h != null) {
                } else {
                    Facility f = currentItem.Item as Facility;
                    if (f != null) {
                    } else {
            private void radTree_Expanded(object sender, Telerik.Windows.RadRoutedEventArgs e) { }
            public void BeginLoadingHospitals(string SystemId) {
                RemitFlowClient proxy = new RemitFlowClient("basic");
                proxy.GetHospitalSystemsCompleted += new EventHandler<GetHospitalSystemsCompletedEventArgs>(GetHospitalSystemsCompleted);
            private void GetHospitalSystemsCompleted(object sender, GetHospitalSystemsCompletedEventArgs e) {
                try {
                    if (e.Error == null && e.Result != null) {
                        List<HospitalSystem> hNodes = new List<HospitalSystem>();
                        hNodes = e.Result;
                        this.radTree.ItemsSource = hNodes;
                } catch {
            public void BeginLoadingFacilities(string SystemId) {
                RemitFlowClient proxy = new RemitFlowClient("basic");
                proxy.GetFacilitiesCompleted += new EventHandler<GetFacilitiesCompletedEventArgs>(GetFacilitiesCompleted);
            private void GetFacilitiesCompleted(object sender, GetFacilitiesCompletedEventArgs e) {
                try {
                    if (e.Error == null && e.Result != null) {
                        List<Facility> fNodes = new List<Facility>();
                        fNodes = e.Result;
                        foreach (Facility facility in fNodes) {
                            RadTreeViewItem newItem = new RadTreeViewItem() {
                                Header = facility.FacilityName,
                                Tag = facility.FacilityId
                            /* ** THIS WILL WORK, But then I can't use the Item Templates!! ** */
                            //    currentItem.Items.Add(newItem);
                        currentItem.ItemsSource = fNodes;
                } catch {
            public void BeginLoadingPayers(string FacilityId) {
                RemitFlowClient proxy = new RemitFlowClient("basic");
                proxy.GetDistinctPayersCompleted += new EventHandler<GetDistinctPayersCompletedEventArgs>(GetPayersCompleted);
            private void GetPayersCompleted(object sender, GetDistinctPayersCompletedEventArgs e) {
                try {
                    if (e.Error == null && e.Result != null) {
                        List<PayerNode> pNodes = new List<PayerNode>();
                        pNodes = e.Result;
                        foreach (PayerNode payer in pNodes) {
                            RadTreeViewItem newItem = new RadTreeViewItem() {
                                Header = payer.PayerName,
                                Tag = payer.PayerId
                            /* ** THIS WILL WORK, But then I can't use the Item Templates!! ** */
                            //    currentItem.Items.Add(newItem);
                        currentItem.ItemsSource = pNodes;
                } catch {

  2. Kiril Stanoev
    Kiril Stanoev avatar
    1512 posts

    Posted 25 Jul 2011 Link to this post

    Hello Joe,

    Unfortunately there are a lot of missing pieces from the code you provided us with and I am unable to reproduce the issue. I've created a simple application demonstrating the proper usage of the LoadOnDemand feature. Please have a look at it and let me know if you manage to reproduce your issue with it. I'll be glad to further assist you.

    All the best,
    Kiril Stanoev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top