Grouping Bug #2

3 posts, 1 answers
  1. Eric
    Eric avatar
    48 posts
    Member since:
    Jul 2012

    Posted 13 Aug 2012 Link to this post

    Hey,

    I'm on a roll tonight! (This may be related to the other one)  Let's say I have directory A, which has children B,C,D,E,F,G.  B has children H,I,J. C  has a child K.  First I delete B by doing A.Children.Remove(B).  Then I move K to have A as a parent: C.Children.Remove(K). A.Children.Add(K).  Now it thinks you've added K twice, and it barfs at you.  After a few hours of poking through your code, I found this is because the internal Index of C was messed up after I removed B.  So when I tried to remove C, it remved the wrong item! I think this is because the code is forgetting that it is also removing children when it removes tasks with children...  Specificly, I think (might be wrong here) that the code in HierarchicalCollectionAdapterBase is not taking this into account (see below).  I should be able to make a simple program to show this bug if nessesary.  Probably what I will end up doing is the DFS myself to hierarchicly remove each item I need to....

    Eric
    As always, using 2012 Q2 wpf
    var startIndex = collectionChangedAction == NotifyCollectionChangedAction.Remove ? oldStartingIndex : newStartingIndex;
     
                    var newWrappers = newItemsCollection != null ? newItemsCollection.OfType<HierarchicalItem>() : Enumerable.Empty<HierarchicalItem>();               
                    var newItemsCount = newItemsCollection != null ? newItemsCollection.Count : 0;
     
                    var oldWrappers = oldItemsCollection != null ? oldItemsCollection.OfType<HierarchicalItem>() : Enumerable.Empty<HierarchicalItem>();
                    var oldItemsCount = oldItemsCollection != null ? oldItemsCollection.Count : 0;
     
                    var removedWrappers = oldWrappers.SelectMany(Flatten).ToArray();
                    var addedWrappers = newWrappers.SelectMany(Flatten).ToArray();
                     
                    var sourceCollectionItemsCountDifference = newItemsCount - oldItemsCount;
                    var childrenCountDifference = addedWrappers.Length - removedWrappers.Length - sourceCollectionItemsCountDifference;
     
                    for (int i = startIndex + newItemsCount; i < targetCollection.Count; i++)
                    {
                        targetCollection[i].previousChildrenCount += childrenCountDifference;
                        targetCollection[i].SourceItemIndex += sourceCollectionItemsCountDifference;
                    }
     
                    var previousChildrenCount = startIndex > 0 ? targetCollection[startIndex - 1].previousChildrenCount + targetCollection[startIndex - 1].visibleChildrenCount : 0;
     
                    foreach (var newWrapper in newWrappers)
                    {
                        newWrapper.previousChildrenCount += previousChildrenCount;
                        previousChildrenCount += newWrapper.visibleChildrenCount;
                    }
  2. Eric
    Eric avatar
    48 posts
    Member since:
    Jul 2012

    Posted 13 Aug 2012 Link to this post

    Hmm,

    I just saw this note:

    "Note that when removing a task, you should also remove programmatically the relations to this item."


    I assumed that meant the dependency arrows, and not the children (otherwise it would have said "of this item").  But still, this could concievably be "by design".  If so, would it be possible to make this more obvious so I don't have to discover an obcure bug to notice this (like throwing an exception if the task you are trying to remove has children)?

    Thanks,
    Eric
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 15 Aug 2012 Link to this post

    Hi Eric,

    Thank you for pointing this issues out. We appreciate any help by the development and improvement of our controls. Our GanttView control is still in beta and we expect a few bugs and your help is even more welcome. You are right, your both posts are related to each other and this known bug, which we try to fix for Q3 2012. Till then you have to drop unfortunately all dependencies to this task which you have to "move" and then you have to adding them again.

    We are sorry for the caused inconvenience.

    Greetings,
    Ventzi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top