4 Answers, 1 is accepted
0
Accepted
Hi Bahram,
I've prepared a small sample demonstrating how you can get the previous and new parent of a task by creating a custom GanttDragDropBehavior. Here's the code of interest:
Please note that I've used the GetItemWrapperByItemKey method to get ahold of the parents but you could alternatively iterate over the TasksSource collection and check each tasks' children.
Please have a look and let me know whether such an approach would work for you.
Regards,
Dilyan Traykov
Progress Telerik
I've prepared a small sample demonstrating how you can get the previous and new parent of a task by creating a custom GanttDragDropBehavior. Here's the code of interest:
protected
override
void
Drop(SchedulingDragDropState state)
{
var task = state.DraggedItem
as
GanttTask;
var item =
this
.Gantt.ExpandCollapseService.HierarchicalCollectionAdapter.GetItemWrapperByItemKey(task);
var previousParent = item.Parent;
base
.Drop(state);
var newItem =
this
.Gantt.ExpandCollapseService.HierarchicalCollectionAdapter.GetItemWrapperByItemKey(task);
var newParent = newItem.Parent;
}
Please note that I've used the GetItemWrapperByItemKey method to get ahold of the parents but you could alternatively iterate over the TasksSource collection and check each tasks' children.
Please have a look and let me know whether such an approach would work for you.
Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0

Bahram
Top achievements
Rank 1
answered on 23 Mar 2019, 09:15 PM
Thank you so much Dilyan! That is definitely what I was looking for.
There is one more thing that you may have a solution for, is there any event or any way that I can access to a task when I draw a relation from it to another(task)?
0
Accepted
Hi Bahram,
I noticed that you opened a private support ticket with your new inquiry but so that it is beneficial to our community, I'm pasting my colleague's reply here as well:
"In order to achieve what you are going for, you can set the DragDependenciesBehavior property of the RadGanttView to a custom behavior. The default class responsible for that is called GanttDragDependenciesBehavior and you can inherit from it. Here is some sample code:
The virtual Link method is called when a connection is made between two tasks. You can also take a look at the other virtual methods to see, if any of them suit your needs better.
Of course, you need to make sure that the custom behavior is initialized as well:
The namespace "local" in the above snippet refers to the namespace where the "CustomDragDependenciesBehavior" class is defined."
Regards,
Dilyan Traykov
Progress Telerik
I noticed that you opened a private support ticket with your new inquiry but so that it is beneficial to our community, I'm pasting my colleague's reply here as well:
"In order to achieve what you are going for, you can set the DragDependenciesBehavior property of the RadGanttView to a custom behavior. The default class responsible for that is called GanttDragDependenciesBehavior and you can inherit from it. Here is some sample code:
public
class
CustomDragDependenciesBehavior : GanttDragDependenciesBehavior
{
protected
override
void
Link(SchedulingLinkState state)
{
base
.Link(state);
}
}
The virtual Link method is called when a connection is made between two tasks. You can also take a look at the other virtual methods to see, if any of them suit your needs better.
Of course, you need to make sure that the custom behavior is initialized as well:
<
telerik:RadGanttView
x:Name
=
"gantt"
TasksSource
=
"{Binding Tasks}"
>
<
telerik:RadGanttView.DragDependenciesBehavior
>
<
local:CustomDragDependenciesBehavior
/>
</
telerik:RadGanttView.DragDependenciesBehavior
>
</
telerik:RadGanttView
>
The namespace "local" in the above snippet refers to the namespace where the "CustomDragDependenciesBehavior" class is defined."
Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0

Bahram
Top achievements
Rank 1
answered on 06 Apr 2019, 06:49 PM
Thank you so much for your help, Dilyan!