Readonly Gantt

12 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 08 May 2013 Link to this post

    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;
            }
    }
  2. Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 09 May 2013 Link to this post

    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.

  3. DevCraft banner
  4. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 09 May 2013 Link to this post

    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>

  5. Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 10 May 2013 Link to this post

    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.

  6. Sedrick Bouknight
    Sedrick Bouknight avatar
    3 posts
    Member since:
    Feb 2009

    Posted 17 May 2013 Link to this post

    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.
  7. Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 22 May 2013 Link to this post

    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.

  8. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 07 Jun 2013 Link to this post

    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). 
  9. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 07 Jun 2013 Link to this post

    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.
  10. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 12 Jun 2013 Link to this post

    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.

  11. Sedrick Bouknight
    Sedrick Bouknight avatar
    3 posts
    Member since:
    Feb 2009

    Posted 12 Jun 2013 Link to this post

    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.
  12. Sebastien
    Sebastien avatar
    11 posts
    Member since:
    Jun 2014

    Posted 12 Aug 2014 in reply to Ventzi Link to this post

    Hello Ventzi,

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

    Thanks a lot
    Sebastien
  13. Sebastien
    Sebastien avatar
    11 posts
    Member since:
    Jun 2014

    Posted 12 Aug 2014 in reply to Sebastien Link to this post

    I found the solution, sorry. My previous post can be removed.
    Thanks a lot
    Sebastien
Back to Top
DevCraft banner