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

How drag and drop works

19 Answers 339 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
hardik
Top achievements
Rank 1
hardik asked on 31 Mar 2011, 08:36 AM
Hi telerik,

Can you please provide information how drag and drop will work for scheudlerView? I see your online demo and tried to understand the logic from code.But I am not able to understand.

EffectivePixelLength, EffectiveOrientation, BehaviorProperty, AppointmentTemplateProperty  are used for which purpose?

"BehaviorBase"  class is used for what ?

In scheduler AppointmentEditing event I have done following code and I can cancel the edit Popup.

How can I do it for scheudlerView?

I am not able to get  AppointmentEditAction  for schedulerView.

if (e.AppointmentEditAction == AppointmentEditAction.Resize)
      {
        e.Cancel = true;
      }

 if (e.AppointmentEditAction != AppointmentEditAction.Drag && e.AppointmentEditAction != AppointmentEditAction.Resize)
      {
        e.Cancel = true;
}

If you provide any example for drag and drop than its good for me.

Thanks
Hardik Pancholi

19 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 05 Apr 2011, 03:45 PM
Hi,


In order to implement a custom drag and drop behavior, I would suggest you to inherit the DefaultDragDropBehavior and set it RadScheduleView.DragDropBehavior. Please, refer to:


 Greetings,
George
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Forest
Top achievements
Rank 1
answered on 16 May 2011, 02:48 PM
Hi

I need to use AppointmentEditAction too.
For example :

If (e.AppointmentEditAction != AppointmentEditAction.Resize)

doesn't work with scheduleView.

Is there any way to use AppointmentEditAction with scheduleView ?
0
hardik
Top achievements
Rank 1
answered on 18 May 2011, 06:20 AM
Hi Forest,

In scheudlerView there isn't anything like AppoitnementEditAction. You have to use CustomDragAndDrop class for re-size and drag & drop.

Thanks
Hardik
SE
0
kjellerik
Top achievements
Rank 1
answered on 15 Jul 2011, 01:02 PM
hi, after updating to latest version of telerik, i could no longer reference DefaultDragDropBehavior ? Has this been changed?

Regards
Kjell Erik 
0
Valeri Hristov
Telerik team
answered on 15 Jul 2011, 01:05 PM
The DefaultDragDropBehavior class is now obsolete. You should use ScheduleViewDragDropBehavior instead (it the same).

Best wishes,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael Lilly
Top achievements
Rank 1
answered on 26 Jul 2011, 09:13 PM
I'm not on the Q2 release of your tools yet, so I'm stuck using the DefaultDragDropBehavior.  Unfortunately, I'm running into a problem that I hope I can solve with this version.

I'm basically using your demo code from the first look example, except changing it to DefaultDragDropBehavior instead of ScheduleViewDragDropBehavior.

The problem I'm seeing is that when I examine the slots I'm dragging over in this class, they aren't marked as IsReadOnly.  They also are just Slots and not my CustomSlot class.

Is this due to using the Default instead of ScheduleView behavior?  Is this something I can fix with the Default version, or do I need to hold off until I'm able to use the ScheduleViewDragDropBehavior class?  I'm guessing it is working correctly in ScheduleViewDragDropBehavior.

Thanks!
0
Valeri Hristov
Telerik team
answered on 27 Jul 2011, 03:35 PM
Hello Michael,

The DestinationSlots collection contains new Slot instances that represent the slots where the dragged appointments will be dropped if the user releases the mouse button. Probably if you describe what you are trying to achieve I should be able to provide more adequate advice?

Greetings,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael Lilly
Top achievements
Rank 1
answered on 27 Jul 2011, 07:17 PM
Correct, I'm looking at the slots in the DestinationSlots collection and even though the slot is marked as IsReadOnly for the SpecialSlots collection, it isn't marked IsReadOnly in the DestinationSlots collection.

When I turn off the custom DragDrop behavior, it works like it's supposed to.  I drag an appointment over a readonly slot and it won't let me drop it, but when I use the custom behavior (code directly from your demo site) it allows me to drop over a readonly slot.  So I looked at the slots in the DestinationSlots collection and none of them are readonly even when they should be.

I'm not trying to do anything really special, just use a custom dragdrop like you have in your First Look in combination with the ReadOnly special slots demo.  I haven't even customized it to my needs yet.
0
Valeri Hristov
Telerik team
answered on 28 Jul 2011, 08:16 AM
Hi Michael,

I understand now. The read-only checking is not publicly available yet. Since the base implementation of the CanDrop method only checks whether any of the DestinationSlots are overlapping with a read-only Slot and returns false in this case, you could call it in your CanDrop method:

public override bool CanDrop(DragDropState state)
{
    return base.CanDrop(state) || /*your custom logic here*/;
}

Best wishes,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael Lilly
Top achievements
Rank 1
answered on 28 Jul 2011, 01:38 PM
Great, thanks, that fixed one problem.  The other problem is if it's a custom slot object, the objects that come in are only Slots.  So I can't have custom logic according to the custom slot object properties.

I was hoping I was just doing something wrong and your first answer would answer this one...that isn't the case.

Is this also something that isn't supported now?
0
Valeri Hristov
Telerik team
answered on 28 Jul 2011, 01:51 PM
The Slot objects in the state.DestinationSlots collection are different than the objects in the RadScheduleView.SpecialSlots collection. In other words, the destination slots are the "coordinates" where the appointments are going to be droppped and the special slots are just places in the schedule. The read-only-ness is still internal to RadScheduleView and cannot be customized yet (but will be some day).

The slots in the two collections are not supposed to be the same, e.g. you should not expect the DestinationSlots collection to contain any of the objects in the SpecialSlots collection.
Greetings,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael Lilly
Top achievements
Rank 1
answered on 28 Jul 2011, 01:58 PM
So you are saying that it's impossible to have custom drag drop logic for a Special Slot?

If that's the case, then I'll have to wait for the user to drop it and handle the logic elsewhere.
0
Valeri Hristov
Telerik team
answered on 28 Jul 2011, 03:34 PM
This is correct. We designed the special slots to be just colored areas in the schedule and later we added the IsReadOnly property. We still don't have many specific use cases for this feature and that's why the API is not very polished yet...

Greetings,
Valeri Hristov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Michael Lilly
Top achievements
Rank 1
answered on 28 Jul 2011, 03:42 PM
That's disappointing.  I was able to implement a lot of things around the Scheduler "special slots" functionality (even if it was more of a rig job).

Our use case is the ability to "Reserve" timeslots for certain types of appointments.  Only an appointment with certain properties can be placed over a reservation.  So when the user does a drag and drop and can't drop on that reservation, I want it to act like a Read Only slot does.  A use case that is probably more universal is that only certain appointment categories can be placed in "Non-working hours".

Although the new ScheduleView implementation of SpecialSlots is much much better than what I had to do in Scheduler, it is missing some very important things.  This is one of them.  Another is the ability to have a tool tip for SpecialSlots (another unanswered thread on the board).  I also will need to handle a right-click context menu that will change whether it's on SpecialSlots or not, but I haven't gotten to that to see if there is an issue there (I'm betting there is).
0
Valeri Hristov
Telerik team
answered on 29 Jul 2011, 12:24 PM
Hi Michael,

Thank you for the feedback. Your use case is very good and we will definitely have it in mind when extending the "special slots" functionality of RadScheduleView.

Best wishes,
Valeri Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Michael Lilly
Top achievements
Rank 1
answered on 10 Aug 2011, 08:17 PM
Just as an update, I was able to get my requested functionality working.

Basically, in the ConflictCheckingDragDropBehavior class, I can access the special slots using this code to get the ScheduleView:

RadScheduleView scheduleViewControl = (RadScheduleView)state.ServiceProvider.GetService<IDialogProvider>();

I can then use the special slots collection to find if the dragged appointment goes over a special slot.  Followed by my custom handling of whether the appointment can be dropped or not.

It still would be cleaner to know if the slot is a special slot or read only slot without having to use the service provider, but for now, this will work for me.  Hopefully others can use this also.
0
Kotte
Top achievements
Rank 1
answered on 08 Sep 2011, 05:43 PM
Hi Valeri Hristov,

RadScheduleView  DragDrop inside RadPanelBar is not working.
It is firing CanStartDrag and CanDrop event never fires.
Here is the code.

<telerik:RadPanelBar  x:Name="radPanelBar1"  IsTextSearchEnabled="False" VerticalAlignment="Stretch" Margin="0" d:LayoutOverrides="VerticalAlignment" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                    <telerik:RadPanelBarItem x:Name="Calendar" 
 HorizontalAlignment="Stretch">
                        <telerik:RadPanelBarItem.Header>
                            <StackPanel Orientation="Horizontal">
                              
                            </StackPanel>
                        </telerik:RadPanelBarItem.Header>
                        <Grid Background="White">
                            <scheduleView:RadScheduleView x:Name="scheduler" ActiveViewDefinitionIndex="2"                                                    telerik:StyleManager.Theme="Windows7"  FontSize="9" FontFamily="Arial"  >
                                <scheduleView:RadScheduleView.ViewDefinitions>
                                    <scheduleView:DayViewDefinition ShowAllDayArea="True"  ShowWeekGroupHeaders="True" />
                                    <scheduleView:WeekViewDefinition ShowAllDayArea="True"  ShowWeekGroupHeaders="True"/>
                                    <scheduleView:MonthViewDefinition VisibleDays="30"  />
                                </scheduleView:RadScheduleView.ViewDefinitions>
                                <telerik:RadScheduleView.DragDropBehavior>
                                    <Calendar:CustomDragDropBehavior></Calendar:CustomDragDropBehavior>
                                </telerik:RadScheduleView.DragDropBehavior>
                            </scheduleView:RadScheduleView>
                        </Grid>
        </telerik:RadPanelBarItem>
</telerik:RadPanelBar> 


 public class CustomDragDropBehavior : ScheduleViewDragDropBehavior 
    {
        public override bool CanDrop(DragDropState state)
        {
            return true;
        }
        public override bool CanStartDrag(DragDropState state)
        {           
            return true;
        }

        public override void Drop(DragDropState state)
        {
            base.Drop(state);
        }

}
0
Rosi
Telerik team
answered on 13 Sep 2011, 08:30 AM
Hi Kotte,

We are aware of this problem and we will do our best to solve the issue for the future versions of the controls. Meanwhile I suggest you set the ExecutionMode of the RadDragAndDropManager to DragExecutionMode.Disabled in order to workaround the problem.

Example:
Copy Code
RadDragAndDropManager.ExecutionMode = DragExecutionMode.Disabled;
InitializeComponent();

!Note that the code is executed before InitializeComponent().

Kind regards,
Rosi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kotte
Top achievements
Rank 1
answered on 13 Sep 2011, 04:32 PM
Hi Rosi,

Thank you for your response.
Its working fine now.


Thanks,
Kotte.
Tags
ScheduleView
Asked by
hardik
Top achievements
Rank 1
Answers by
George
Telerik team
Forest
Top achievements
Rank 1
hardik
Top achievements
Rank 1
kjellerik
Top achievements
Rank 1
Valeri Hristov
Telerik team
Michael Lilly
Top achievements
Rank 1
Kotte
Top achievements
Rank 1
Rosi
Telerik team
Share this question
or