LoadOnDemand in async Data Query

5 posts, 1 answers
  1. SangGyu Kim
    SangGyu Kim avatar
    9 posts
    Member since:
    Jul 2008

    Posted 30 Oct 2008 Link to this post

    In LoadOnDemandTimer_Tick handler, I want to bind data source object from WCF.

    When i add static object it works, but add from WCF node expanding icon is spinning continuously.

    private void LoadOnDemandTimer_Tick(object sender, EventArgs e)
            {

                Department dpt = this.currentTreeViewItem.Item as Department;
                          Department sub = new Department();
                sub.DepartmentName = "sub";
                sub.Departmentid = "code";

                dpt.Children.Add(sub);  //<-- it works fine

                TreeViewORGDataSource relSubSource = new TreeViewORGDataSource();
                relSubSource.FillByCompayCode(dpt.CompanyCode);
                if (relSubSource.Count > 0)
                {
                    foreach (Department item in relSubSource[0].Children)
                    {
                        dpt.Children.Add(item);
                    }
                }
                this.currentTreeViewItem.IsExpanded = true;
                (sender as DispatcherTimer).Stop();
            }

    FillByCompayCode method is WCF binding method.

    I guess the reason is  FillByCompayCode method is asyncronous.

    How can i it works?

  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 31 Oct 2008 Link to this post

    Hi SangGyu Kim,

    Check-out this example for a solution about how to use the Load On Demand functionality with services:
    http://blogs.telerik.com/ValeriHristov/Posts/08-10-08/Silverlight_TreeView_Load_on_Demand.aspx?ReturnURL=%2fValeriHristov%2fPosts.aspx

    About your problem - yes most probably the reason is that the data is not available when you try to add it. Just make sure that your data source is populating with the WCF service and all should be set.

    Best wishes,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. SangGyu Kim
    SangGyu Kim avatar
    9 posts
    Member since:
    Jul 2008

    Posted 31 Oct 2008 Link to this post

    I followed your guide.
    In this case, When the data source was changed it worked fine, but data source was empty, it didn't make any differences.

    In my thought, the reason is that data source's change notify event not fired.

    Is there any way that notify to TreeView that data loading is complete anyway?

    Can I handle this?
  4. SangGyu Kim
    SangGyu Kim avatar
    9 posts
    Member since:
    Jul 2008

    Posted 31 Oct 2008 Link to this post

    I followed your guide.
    In this case, When the data source was changed it worked fine, but data source was empty, it didn't make any differences.

    In my thought, the reason is that data source's change notify event not fired.

    Is there any way that notify to TreeView that data loading is complete anyway?

    Can I handle this?
  5. Answer
    Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 01 Nov 2008 Link to this post

    Hello SangGyu Kim,

    To stop the loading animation you can set the IsLoadingOnDemand property to false to the RadTreeViewItem. this will stop the animation.

    If you want to remove the expander icon from the Item, just set the IsLoadOnDemandEnabled to false and this will do it.

    Let us know if you have any other difficulties.

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top