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

Grouping Bug #2

2 Answers 59 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 14 Aug 2012, 03:48 AM
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 Answers, 1 is accepted

Sort by
0
Eric
Top achievements
Rank 1
answered on 14 Aug 2012, 03:59 AM
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
0
Accepted
Ventzi
Telerik team
answered on 15 Aug 2012, 08:59 AM
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.

Tags
GanttView
Asked by
Eric
Top achievements
Rank 1
Answers by
Eric
Top achievements
Rank 1
Ventzi
Telerik team
Share this question
or