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

Get a ganttTask in SchedulingResizeBehavior class

2 Answers 58 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Natalia
Top achievements
Rank 1
Natalia asked on 09 Jun 2014, 04:29 PM
Hi,

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 Answers, 1 is accepted

Sort by
0
Accepted
Polya
Telerik team
answered on 10 Jun 2014, 08:25 AM
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.

Regards,
Polya
Telerik
 
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.
 
0
Natalia
Top achievements
Rank 1
answered on 10 Jun 2014, 09:25 AM
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
Tags
GanttView
Asked by
Natalia
Top achievements
Rank 1
Answers by
Polya
Telerik team
Natalia
Top achievements
Rank 1
Share this question
or