LoadOnDemand seems on wrong object

4 posts, 0 answers
  1. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 22 Feb 2011 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 24 Feb 2011 Link to this post

    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!
  3. UI for WPF is Visual Studio 2017 Ready
  4. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 24 Feb 2011 Link to this post

    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;

  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 01 Mar 2011 Link to this post

    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!
Back to Top