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

Change default appointment duration

3 Answers 145 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 26 Nov 2012, 01:21 PM

Hello!

In my application I have a ListBox and RadScheduleView. I can create a new appointment by drag'n'drop from ListBox. Default duration for new appointment is 1 hour.

I have a  ScheduleViewDragDropBehavior class and I tried to set End property for new appoinment here, but Start and End properties are equal 1000/01/01. 

public class ScheduleViewDragDropBehavior : Telerik.Windows.Controls.ScheduleViewDragDropBehavior
    {
        public override IEnumerable<IOccurrence> ConvertDraggedData(object data)
        {
            if (DataObjectHelper.GetDataPresent(data, typeof(Campaign), false))
            {
                var campaigns = DataObjectHelper.GetData(data, typeof(Campaign), true) as IEnumerable;
                if (campaigns != null)
                {
                    var appCollection = campaigns.OfType<Campaign>().Select(c => new AppointmentCampaign { Subject = c.Name, Campaign = c, Category = new Category("", c.Brush) });
 
                    return appCollection;
                }
            }
            return base.ConvertDraggedData(data);
        }
    }
 

So, how can I change default duration?

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 29 Nov 2012, 11:19 AM
Hello Andrey,

You should override CanDrop method in your ScheduleViewDragDropBehavior and change the End time of the destination slot. Here is an example:

public override bool CanDrop(Telerik.Windows.Controls.DragDropState state)
{
    var destSlot = state.DestinationSlots.First();
    destSlot.End = destSlot.Start.AddHours(2);
    return base.CanDrop(state);
}

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Accepted
Yana
Telerik team
answered on 29 Nov 2012, 11:49 AM
Hi Andrey,

Actually it should be like this:

public override bool CanDrop(Telerik.Windows.Controls.DragDropState state)
{
    if (state.DestinationAppointmentsSource != state.SourceAppointmentsSource)
    {
        var destSlot = state.DestinationSlots.First();
        destSlot.End = destSlot.Start.AddHours(2);
    }
    return base.CanDrop(state);
}

The condition is needed to distinguish whether the appointment is dragged from outside the ScheduleView.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Andrey
Top achievements
Rank 1
answered on 29 Nov 2012, 12:28 PM
It works fine! Thank you!
Tags
ScheduleView
Asked by
Andrey
Top achievements
Rank 1
Answers by
Yana
Telerik team
Andrey
Top achievements
Rank 1
Share this question
or