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

LoadOnDemand seems on wrong object

3 Answers 55 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
heavywoody
Top achievements
Rank 1
heavywoody asked on 22 Feb 2011, 06:08 PM
I created a test application I put URL at bottom.  I am getting weird behavior.  The situation is that we have a dynamic workflow that the treeview will read at runtime, ondemand.  So the workflow for all the same type objects is the same, which seems to throw off the treeview.  So follow these steps and you should see what I mean:

1) Expand "Arrow Canyon" and select a child node "Comment"
2) Now expand another section like "Buck Mountain".  Notice that "Comment" is already selected just like the first section.
3) Now select a different child item under "Buck Mountain", like Reference.  Notice what changes is the items under "Arrow Canyon".

So even though they are different instances, it always acts like you are working with the first instance.  And in fact, in my program I am writing, every reference is to the first section, no matter which instance I am using.

I figured  it had something to do with each node using the same workflow.  But they are different instances, so I assumed this would be fine.  Perhaps you could educate me on how I should be using this correctly so only one item is selected at a time and it is in the correct section?

http://www.geostratsys.org/DrillDownTest.zip

3 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 24 Feb 2011, 01:55 PM
Hello Christian Loepp,

As I mention in your support ticket, it seems that the archive you sent is corrupted and therefore I am not sure what is your scenario. However, I will post my guess here as well, should anyone else encounter it:

When you define one collection of items as the ItemsSource of multiple RadTreeViewItems, then the RadTreeView ItemsSource collection will contain multiple instances of one data item. Then the logic of the selection, drag/drop, check state operations etc, will always work with the first instance of that data item. Therefore you need to make sure that on LoadOnDemand each RadTreeViewItem ItemsSource collection is populated with new collection of items.

I hope this info helps.

Best wishes,
Tina Stancheva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
heavywoody
Top achievements
Rank 1
answered on 24 Feb 2011, 03:33 PM
My apologizes.  The link I posted  should work now.

What throws me off is I am using the same source for the query, but they are separate.  Here is my code that is populating each item as it doe the OnDemand.  Notice I am explicityly giving different source:

 

private void treeMain_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadTreeViewItem selItem = e.OriginalSource as RadTreeViewItem;
            switch (selItem.Item.GetType().Name)
            {
                case "WorkFlow":

                    break;
                case "Section":
                    Section selSection = selItem.Item as Section;
                       var items = from w in _ctx.WorkFlows
                            where w.ParentID == 1
                            select w;
                        foreach (var item in items)
                        {
                            //Add child workflow to each section that is drilled into
                            selItem.Items.Add(item);
                        }
                        selItem.IsLoadingOnDemand = false;
                    break;

0
Tina Stancheva
Telerik team
answered on 01 Mar 2011, 02:51 PM
Hello Christian Loepp,

As I noted in your support ticket, the approach you took is good. Therefore, I will attach the  sample application illustrating it here as well if anyone else come across the same issue.

Greetings,
Tina Stancheva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeView
Asked by
heavywoody
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
heavywoody
Top achievements
Rank 1
Share this question
or