Block used from selecting weekends / holidays

4 posts, 0 answers
  1. Ian
    Ian avatar
    2 posts
    Member since:
    Jan 2014

    Posted 07 Feb 2014 Link to this post

    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
  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 11 Feb 2014 Link to this post

    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).

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ian
    Ian avatar
    2 posts
    Member since:
    Jan 2014

    Posted 20 Feb 2014 in reply to Dimitar Link to this post

    Thanks, I will trial shortly.

    Regards
    Ian
  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 25 Feb 2014 Link to this post

    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
Back to Top