Get a ganttTask in SchedulingResizeBehavior class

3 posts, 1 answers
  1. Natalia
    Natalia  avatar
    4 posts
    Member since:
    Mar 2014

    Posted 09 Jun 2014 Link to this post


    I'm using a RadGanttView control and need some help with the next problem: I have created a CustomResizeBehavior class that inherits SchedulingResizeBehavior class to customize a resizing behavior. I want to deny the resizing of some gantt tasks. So I need to get the task that is resized on the GanttChart and override CanResize method in some way. More particular: I have a couple of classes that inherit IGanttTask, and for some of them I need to restrict resizing. That's why I need to have an access to the gantt task in the CanResize method. Is there any way to get it?

    Thank you,
    Natalia  Novosad
  2. Answer
    Polya avatar
    199 posts

    Posted 10 Jun 2014 Link to this post

    Hello Natalia,

    When overriding CanResize the parameter passed in the method is of type SchedulingResizeState. This state contains an IDateRange ResizedItem, that is the IGanttTask we are trying to resize. Here is a small code snippet that allows resizing only for IGanttTasks that have an End date before today.
    protected override bool CanResize(SchedulingResizeState state)
        var task = state.ResizedItem as IGanttTask;
        if (task.End >= DateTime.Now)
            return false;
        return base.CanResize(state);

    Also depending on your scenario, you might want to consider overriding CanStartResize instead of CanResize method as the first specifies whether the resize operation can be started, while the second specifies whether the resize operation can be completed.

    Hopefully this helps.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Natalia
    Natalia  avatar
    4 posts
    Member since:
    Mar 2014

    Posted 10 Jun 2014 in reply to Polya Link to this post

    Hi Polya,

    Thank you for such an extended reply. Actually, I did see that ResizedItem property of IDateRange type but it didn't seem to be of IGanttTask type. But it works perfectly. Thanks!

    Kind regards,
    Natalia Novosad
Back to Top