
However, at this time, I would just like to keep the gantt read-only. Users should only be able to view it, not modify it. I don't see any properties like IsReadOnly, AllowEdit, CanUserResize, etc. Setting IsEnabled=false will not work for me as you cannot select a project, nor scroll when this is set.
I created custom Resize and DragDrop behaviors. The custom DragDrop behavior appears to be working as I can no longer drag/drop projects. However I can still resize them. I also don't want the user to be able to create relations in the gantt. How can I achieve this?
public
class
NoResizingBehavior : SchedulingResizeBehavior
{
protected
override
bool
CanResize(SchedulingResizeState state)
{
return
false
;
}
protected
override
bool
CanStartResize(SchedulingResizeState state)
{
return
false
;
}
}
public
class
NoDragDropBehavior : Telerik.Windows.Controls.GanttView.GanttDragDropBehavior
{
protected
override
bool
CanDrop(SchedulingDragDropState state)
{
return
false
;
}
protected
override
bool
CanStartDrag(SchedulingDragDropState state)
{
return
false
;
}
}
11 Answers, 1 is accepted
If you need to restrict the linking between the GanttTasks, you could create custom DragDependenciesBehavior which should inherit from SchedulingLinkBehavior. Then you need to override the CanStartLink method like following:
public class CustomDragDependenciesBehavior : SchedulingLinkBehavior
{
protected override bool CanStartLink(SchedulingLinkState state)
{
return false;
}
.....
}
The last thing you should do is to set the DragDependenciesBehavior property of the RadGanttView to your newly created custom behavior like this:
<
telerik:RadGanttView.DragDependenciesBehavior
>
<
local:CustomDragDependenciesBehavior
/>
</
telerik:RadGanttView.DragDependenciesBehavior
>
I hope this helps.
Regards,
Ventzi
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

However, I am still able to resize the projects. Here is my code to disable resizing, which doesn't appear to have any affect.
public class NoResizingBehavior : SchedulingResizeBehavior
{
protected override bool CanResize(SchedulingResizeState state)
{
return false;
}
protected override bool CanStartResize(SchedulingResizeState state)
{
return false;
}
}
<
telerik:RadGanttView.ResizeBehavior
>
<
my:NoResizingBehavior
/>
</
telerik:RadGanttView.ResizeBehavior
>
I am not sure I understand you fully, are you trying to resize the project (the Gantt control itself) or you are trying to resize each individual GanttTask inside the RadGanttView? In case you are resizing the GanttTask your code works perfect. For reference please try the attached project. If you are confused from the resize cursor, you could override the EventDecoratorContainerTemplate (which contains the ResizeStart and ResizeEnd elements) by setting the value of the Cursor to Arrow.
I'm looking forward to your response.
Regards,
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

The readonly behavior should not allow the modification of any of the visual items that would represent the task data.
If the task has a set start|end date, then the user should not be allowed to perform any operation that would change that (eg stretch, drag, resize etc).
Scrolling (primarily) and selection capabilities should be preserved however.
In order to have a readonly RadGanttView you need to create custom GanttDragDropBehavior, SchedulingResizeBehavior and GanttDragDependenciesBehavior. Creating this custom behaviors you will prevent the dragging, resizing and linking in the RadGanttView. You could find information how to do this here, here, here and in the posts above.
Hope this helps.
Regards,
Ventzi
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

To reiterate -- I do not want the user to be able to resize tasks (I want to prevent changing of start/end dates).

1. In my datasource, I have not dependencies or children. Its just a flat list of tasks.
2. My tasks are of a custom class that inherits from GanttTask.
I am currently altering your sample project to reflect my scenario to see if I can reproduce with the sample project.
I tried to reproduce the problem at our side, but with no avail. Please take a look at the attached sample project and let me know if I'm missing something.
Regards,
Miroslav Nedyalkov
Telerik
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

<telerik:RadGanttView.ResizeBehavior>
<behavior:LockResizeBehavior/>
</telerik:RadGanttView.ResizeBehavior>
<telerik:RadGanttView.DragDropBehavior>
<behavior:LockDragDropBehavior/>
</telerik:RadGanttView.DragDropBehavior>
<telerik:RadGanttView.DragDependenciesBehavior>
<behavior:LockDragDependenciesBehavior/>
</telerik:RadGanttView.DragDependenciesBehavior>
...And that did it.

Can you provide the full class CustomDragDependenciesBehavior. I didn't succeed to implement it yet.
Thanks a lot
Sebastien

Thanks a lot
Sebastien