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

Block used from selecting weekends / holidays

3 Answers 89 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 07 Feb 2014, 01:14 PM
Hi

I am using the GanttView in edit mode to allow users to move start/end dates using the graphical view by dragging the start/end dates with the mouse.

I would like to prevent users from selecting certain dates and weekends ie to prevent start/end dates being set to a saturday, sunday or any other dates that I might not require them to use (i.e bank holidays / non-work days).

Is there a way to achieve this?

Thanks
Ian

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 Feb 2014, 02:37 PM
Hello Ian,

Thank you for writing us.

To achieve such functionality you can override the default GanttViewBehavior. In this case you can override the ProcessMouseMoveWhenResizingTask method in order to disable specific dates:
public class MyBehaviour : BaseGanttViewBehavior
{
    protected override void ProcessMouseMoveWhenResizingTask(GanttGraphicalViewBaseTaskElement element, MouseEventArgs e)
    {
        Point mousePosition = this.GanttViewElement.GraphicalViewElement.PointFromControl(e.Location);
        int distanceFromLeftBorder = this.GanttViewElement.GraphicalViewElement.HorizontalScrollBarElement.Value + mousePosition.X;
        DateTime newStart = this.GanttViewElement.GraphicalViewElement.TimelineBehavior.AdjustedTimelineStart.AddSeconds(distanceFromLeftBorder * this.GanttViewElement.GraphicalViewElement.OnePixelTime.TotalSeconds);
 
        DateTime forbiddendDay = new DateTime(2010, 12,10);
 
        
        if (newStart.Date.Day == forbiddendDay.Date.Day)
        {
             
            return;
        }
        base.ProcessMouseMoveWhenResizingTask(element, e);
    }
}

The default behaviour can be changed with the following line of code:
this.radGanttView1.GanttViewBehavior = new MyBehaviour();

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Dimitar
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Ian
Top achievements
Rank 1
answered on 20 Feb 2014, 02:09 PM
Thanks, I will trial shortly.

Regards
Ian
0
Dimitar
Telerik team
answered on 25 Feb 2014, 08:53 AM
Hi Ian,

Thank you for writing back.

Take as much time as you need to examine this. If you have additional questions do not hesitate to contact us.

Regards,
Dimitar
Telerik
Tags
GanttView
Asked by
Ian
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Ian
Top achievements
Rank 1
Share this question
or