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

LoadOnDemand in async Data Query

4 Answers 125 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
SangGyu Kim
Top achievements
Rank 1
SangGyu Kim asked on 31 Oct 2008, 03:26 AM

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?

4 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 31 Oct 2008, 07:17 AM
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.
0
SangGyu Kim
Top achievements
Rank 1
answered on 31 Oct 2008, 10:33 PM
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?
0
SangGyu Kim
Top achievements
Rank 1
answered on 31 Oct 2008, 10:34 PM
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?
0
Accepted
Valentin.Stoychev
Telerik team
answered on 01 Nov 2008, 09:20 AM
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.
Tags
TreeView
Asked by
SangGyu Kim
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
SangGyu Kim
Top achievements
Rank 1
Share this question
or