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

Appointment: validate changes during drag&drop

3 Answers 87 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Björn
Top achievements
Rank 1
Björn asked on 13 Feb 2012, 04:40 PM
Hi
1)
I want to check, if a user can Drag&Drop an appointment to a new date.
For that I catch in OnAppointmentEditingCommand the AppointmentEditedEventArgs
and set the e.Cancel=true, if it's not allowed.
To validate the changes, I need the orginal and changed data - but the changed data are missing!
Where can I find in the AppointmentEditedEventArgs the changed data?

2)
We display in the scheduler different calendars (resources). It's not allowed to drag&drop an appointment to another calendar.
Need for that the changed resources collection in AppointmentEditedEventArgs or what to do?

3)
Other way to check the values is in the OnAppointmentEditedCommand.
Then I have to remember the orginal state before and compare that with the values in AppointmentEditedEventArgs.
But To cancel the changes, it's not possible to use  e.Handled = false;
What's the idea of the e.Handled?

Thanks for help.
Björn.

3 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 16 Feb 2012, 02:40 PM
Hello Bjorn,

For drag-drop validation I would recommend using a custom ScheduleViewDragDropBehavior and checking the validity of the operation in the CanDrop method. You have access to the original appointments in the state.DraggedAppointments collection and to the properties that will be applied in the state.DestinationSlots collection. With this approach you should be easily able to accomplish all three tasks.

The ScheduleViewDragDropBehavior class inherits from DependencyObject so you should be able to add dependency properties and bind them to your view model if needed.

All the best,
Valeri Hristov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Predrag
Top achievements
Rank 1
answered on 30 Mar 2012, 12:55 PM

Hi Valeri,

 

I’m using custom ScheduleViewDragDropBehavior and I would like to do the validation on Drop. For this I need my ViewModel, so I tried to create ICommand dependency properties on my custom drag-drop behavior and bind them to the corresponding properties in the ViewModel. I have problem it seems that ScheduleViewDragDropBehavior is NOT a DependencyObject. I managed to get ViewModel using:

var scheduleView = state.ServiceProvider.GetService<IObjectEditor<IAppointment>>() as RadScheduleView;

And than scheduleView.DataContext property.
This is workaround is it possible to bind ScheduleViewDragDropBehavior to the ViewModel?

Thanks for help.
Predrag

0
Miroslav Nedyalkov
Telerik team
answered on 04 Apr 2012, 09:26 AM
Hi Predrag,

The default DragDropBehavior is not a DependencyObject as it is designed to be shared between many ScheduleViews and because of this it should be stateless. What I would suggest you is to either your work-around or to create a property for the ViewModel at your custom behavior and set it once the page is initialized.

Hope this helps.

Kind regards,
Miroslav Nedyalkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ScheduleView
Asked by
Björn
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Predrag
Top achievements
Rank 1
Miroslav Nedyalkov
Telerik team
Share this question
or