I have GanttView. When I click on empty space of timeline I need scroll to task on this row. How I can do this?
1 Answer, 1 is accepted
0
Polya
Telerik team
answered on 05 Feb 2015, 08:54 AM
Hi Alexander,
In order to achieve that we need to:
1) Add a MouseLeftButtonDown event handler to the BorderContainer (that is used as a placeholder for the row). Note that if you have SpecialSlotContainers you need to add the same handler to them as well because they are drawn on top of the BorderContainers.
public MainWindow()
{
InitializeComponent();
EventManager.RegisterClassHandler(typeof(BorderContainer), UIElement.MouseDownEvent, new MouseButtonEventHandler(OnMouseDown), true);
2) Implement the method FlattenSource that flattens the TasksSource of the RadGanttView in an IEnumerable<IGanttTask> and takes into account whether the GanttTasks are expanded or collapsed to extract the correct GanttTask corresponding to the BorderInfo.CellCoordinates.Start.
var hierarchicalParent = parentGantt.ExpandCollapseService.HierarchicalCollectionAdapter.GetItemWrapperByItemKey(parent);
var child = parentGantt.ExpandCollapseService.HierarchicalCollectionAdapter.GetItemWrapperByItemKey(item);
if (hierarchicalParent.IsExpanded && (child.Children.Count == 0 || child.IsExpanded))
{
yield return item as IGanttTask;
}
}
}
Please note that the FlattenSource method will work correctly only for two levels of hierarchy, so you will need to improve it to support three or four levels by calling the same method recursively.
3) Finally set the RadGanttView.SelectedItem to the task from 2).
Hopefully this helps.
Regards,
Polya
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.