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

Readonly Gantt

11 Answers 218 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 08 May 2013, 09:32 PM
I have been using your gantt chart since it was in beta.  I recently updated my controls and am happy to see there is more editing capabilities. (drag/drop, expand, connect, etc)

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

Sort by
0
Ventzi
Telerik team
answered on 09 May 2013, 08:25 AM
Hello Justin Lee,

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.

0
Justin Lee
Top achievements
Rank 1
answered on 09 May 2013, 01:45 PM
Yes, that worked to not allow setting up dependencies.

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>

0
Ventzi
Telerik team
answered on 10 May 2013, 08:23 AM
Hi Justin Lee,

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,

Ventzi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Sedrick Bouknight
Top achievements
Rank 1
answered on 17 May 2013, 09:55 PM
I have the same requirement...

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.
0
Ventzi
Telerik team
answered on 22 May 2013, 07:18 AM
Hi Sedrick,

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 hereherehere and in the posts above.

Hope this helps. 

Regards,
Ventzi
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Justin Lee
Top achievements
Rank 1
answered on 07 Jun 2013, 05:53 PM
I am still unable to prevent resizing.  The link you provided is where I got my code to do it.  I'm returning false for both CanResize and CanStartResize, but it is still allowing the user to resize the tasks.  (please see my code in previous post)  Is there something else I need to override?

To reiterate -- I do not want the user to be able to resize tasks (I want to prevent changing of start/end dates). 
0
Justin Lee
Top achievements
Rank 1
answered on 07 Jun 2013, 05:58 PM
Here is some more info:
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.
0
Miroslav Nedyalkov
Telerik team
answered on 12 Jun 2013, 04:36 PM
Hello Justin,

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.

0
Sedrick Bouknight
Top achievements
Rank 1
answered on 12 Jun 2013, 04:44 PM
The links from the 22 May post work perfectly for me...  Clunky and not as elegant as ReadOnly="true" in markup, but it worked perfectly for me.  After creating those elements the final interior xaml markup was:

<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.
0
Sebastien
Top achievements
Rank 1
answered on 12 Aug 2014, 01:00 PM
Hello Ventzi,

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

Thanks a lot
Sebastien
0
Sebastien
Top achievements
Rank 1
answered on 12 Aug 2014, 01:11 PM
I found the solution, sorry. My previous post can be removed.
Thanks a lot
Sebastien
Tags
GanttView
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Ventzi
Telerik team
Justin Lee
Top achievements
Rank 1
Sedrick Bouknight
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Sebastien
Top achievements
Rank 1
Share this question
or