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

Drag Drop Appointment - move an other appoitment too

15 Answers 79 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
ITA
Top achievements
Rank 1
ITA asked on 07 Dec 2013, 01:18 PM
Hi,

we use the SchduleView to plan our staff. Works great and we are very happy with this control. Now we have this situation:

Two employees are planed for the same service oder. Now I we change the time for this work by moving the appointment from
one employee and we want, that the second appointment of the second employee will move too! Is this possible and how do
we solve this?

Thanks a lot
best regards
Rene

15 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 10 Dec 2013, 01:14 PM
Hello Rene,

I assume you are using ScheduleView Resources in order to display the employees. What you can do is to set multiple Resource on a single Appointment by setting the AllowMultipleSelection property of the ResourceType to true. This way the same Appointment will be shown for the both Resources and when you drag one of them, the other will be also dragged.

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 11 Dec 2013, 09:59 AM
Hi,

i tried to set my ResourceType to "AllowMultipleSelection" on true, but without any effects. I have to appointments with the same ResourceType Value "XX". I can see the ResourceType in the apooitnment, but i a drag one the other will not move.

Is there any simple Exmaple somewhere?

Thanks
Rene
0
Kalin
Telerik team
answered on 11 Dec 2013, 02:42 PM
Hello Rene,

The AllowMultipleSelection property allows multiple Resources to be selected from the drop down in the EditAppointmentDialog. If you are adding the Appointments in the code behind you would just need to add the desired resources to the Appointment. Please check the attached sample project which demonstrates the approach.

Hope this works for you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 11 Dec 2013, 03:09 PM
Hi,

i think this is a misunderstanding. In your example you have one appointment which is shown in two groups! I have many different appointments and some of them have the same group like "Room 1". Now i want to drag & drop one appointment from "Room 1" and
all the other appointments from "Room 1" should be dragged too!

I have one employee, a car and a mower. My Car and the machine are resources which need to be planned like an employee.
And if i change the appointment for the employee the appointment for the car and the mower must change too!

Thanks
Rene
0
Kalin
Telerik team
answered on 12 Dec 2013, 02:18 PM
Hello Rene,

I'm sorry for the misunderstanding. What you need to do is to override the CoerceDraggedItems in order to select all the Appointments with same resource when start dragging. The method should look like showed below:

public override IEnumerable<IOccurrence> CoerceDraggedItems(DragDropState state)
{
    var resource = (state.Appointment as Appointment).Resources.First();
    var allAppointments = state.SourceAppointmentsSource.Cast<IOccurrence>();
    var desiredAppointments = allAppointments.Where(a => (a as Appointment).Resources.Any(r => r == resource));
 
    return desiredAppointments;
}

Please try it and let me know if this works for you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 16 Dec 2013, 02:06 PM

Hi,



I created a public class called "ScheduleViewDragDropBehavior" and I created this:



<telerik:RadScheduleView.DragDropBehavior>
       <local:ScheduleViewDragDropBehavior />
</telerik:RadScheduleView.DragDropBehavior>



Ok works fine, but how do I get the appointmens in desiredAppointments with the same source called "Ursache"?



And a second question in this case. How do I get ALL dragged appointments in the void

"void DragDropCompleted(object sender, DragDropCompletedEventArgs e)"



Thanks a lot

Best Regards

Rene


0
Kalin
Telerik team
answered on 17 Dec 2013, 03:24 PM
Hi Rene,

I'm not sure if I'm understanding your first question correctly. The code snippet from my previous post achieves exactly the required functionality - when you move a single Appointment all other Appointments with the same Resource are moving. As for the second question you can easily find the dragged appointments in the DragDropCompleted method in the DragDropState the following way - state.DraggedAppointments.

I'm attaching a sample project which demonstrates the explained above, please check it and let me know if it helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 18 Dec 2013, 07:58 AM
Hi Kalin,

this is it!

But one more question! I use more than one resourceType. In your example the resource is a room and the resourceType
is location. I use four resourcetyps. How can i select one of them is this case?

var desiredAppointments = allAppointments.Where(a => (a as Appointment).Resources.Any(r => r == resource));

Thanks a lot
Best Regards
Rene
0
ITA
Top achievements
Rank 1
answered on 18 Dec 2013, 09:15 AM
Hi Kalin,

just one more question....

you handle the DragDropCompleted Event in the CustomDragDropBehavior Class. Is it possible to call a void in the MainWindow.cs out of your CustomDragDropBehavior.cs?

The Problem ist, that i open a EDP-Session to a business-Software (EDP GlobalEDP = new EDP(); GlobalEDP.BeginSession... ). I need the GlobalEDP to write back into the Database.

Thanks
Best Regards
Rene
0
ITA
Top achievements
Rank 1
answered on 18 Dec 2013, 03:02 PM
Hi,

nearly solved! I use your example to explain the problem:

XAML
<Window x:Class="ScheduleViewCustomDragDropBehaviorWPF.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                xmlns:local="clr-namespace:ScheduleViewCustomDragDropBehaviorWPF"
                Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Grid>
        <telerik:RadScheduleView x:Name="ScheduleView" FirstVisibleTime="6:0:0" FirstDayOfWeek="Monday" >          
            <telerik:RadScheduleView.ResourceTypesSource>
                <telerik:ResourceTypeCollection>
                    <telerik:ResourceType Name="Location">
                        <telerik:Resource ResourceName="Room 1" />
                        <telerik:Resource ResourceName="Room 2" />
                        <telerik:Resource ResourceName="Room 3" />
                    </telerik:ResourceType>
                    <telerik:ResourceType Name="Ursache">
                        <telerik:Resource ResourceName="U 1" />
                        <telerik:Resource ResourceName="U 2" />
                        <telerik:Resource ResourceName="U 3" />
                    </telerik:ResourceType>
                </telerik:ResourceTypeCollection>
            </telerik:RadScheduleView.ResourceTypesSource>
             
            <telerik:RadScheduleView.DragDropBehavior>
                <local:CustomDragDropBehavior />
            </telerik:RadScheduleView.DragDropBehavior>
 
            <telerik:RadScheduleView.ViewDefinitions>
                <telerik:DayViewDefinition Orientation="Vertical" TimerulerMajorTickStringFormat="{}{00:HH}:{00:mm}" DayStartTime="06:00" DayEndTime="18:00" MinorTickLength="15min"  />
                <telerik:WeekViewDefinition  Orientation="Horizontal" TimerulerMajorTickStringFormat="{}{00:HH}:{00:mm}" DayStartTime="06:00" DayEndTime="18:00" MinorTickLength="15min" />
                <telerik:MonthViewDefinition  />
                <telerik:TimelineViewDefinition TimerulerMajorTickStringFormat="{}{00:HH}:{00:mm}" MinorTickLength="15min" DayStartTime="06:00" DayEndTime="18:00" />
            </telerik:RadScheduleView.ViewDefinitions>
        </telerik:RadScheduleView>
    </Grid>
</Window>

MainWindow.xaml.cs:
private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ObservableCollection<Appointment> appointments = new ObservableCollection<Appointment>();
 
            Appointment yyy = new Appointment();           
            yyy.Start = Convert.ToDateTime("18.12.2013 14:00:00");
            yyy.End = Convert.ToDateTime("18.12.2013 16:00:00");
            yyy.Subject = "Test";
            yyy.Body = "Body";
            yyy.Resources.Add(new Resource("Room 1", "Location"));
            appointments.Add(yyy);
 
            Appointment zzz = new Appointment();
            zzz.Start = Convert.ToDateTime("18.12.2013 17:00:00");
            zzz.End = Convert.ToDateTime("18.12.2013 18:00:00");
            zzz.Subject = "Test";
            zzz.Body = "Body";
            zzz.Resources.Add(new Resource("Room 1", "Location"));
            appointments.Add(zzz);
 
            this.ScheduleView.AppointmentsSource = appointments;             
        }

As you can see i create an ObservableColletion of Appointments and i set the ResourceType "Location" to "Room 1". Double Click the Appointment will show me "Room 1". Now i drag one of this Items and the second is "NOT" dragged too!!!!!
Now i change the Location in Appointment Dialog to "Room 2" in both Appointments and i drag one of them, second "IS" dragged to as expected!

Where is the problem? I can't attach the zip again sorry?

Best Rergards
Rene
0
ITA
Top achievements
Rank 1
answered on 20 Dec 2013, 08:20 AM
Hi,

no idea? is it a bug?

thanks
best regards
Rene
0
Accepted
Kalin
Telerik team
answered on 20 Dec 2013, 11:46 AM
Hello,

The reason for this is that you are adding different Resource instances for each of the Appointments. So you could either pass the same instance or can check if the Appointments match by comparing their DisplayName instead of the Resource itself:
var desiredAppointments = allAppointments.Where(a => (a as Appointment).Resources.Any(r => r.DisplayName == resource.DisplayName));

Hope this will work for you.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ITA
Top achievements
Rank 1
answered on 20 Dec 2013, 11:59 AM
Hi,

i love you guys. Thanks a lot that's it!

Wish you merry X-Mas and a happy new Year !!!!!!!!

best regards
Rene
0
ITA
Top achievements
Rank 1
answered on 28 Jan 2014, 07:01 AM
Hi,

sorry one more question in this case. This works fine:

var desiredAppointments = allAppointments.Where(a => (a as Appointment).Resources.Any(r => r.DisplayName == resource.DisplayName));

I must also consider whether the r.DisplayName is not "-"?

Thanks a lot
Best Regards
R
0
Kalin
Telerik team
answered on 31 Jan 2014, 08:19 AM
Hi Rene,

As far I understand your requirement you might need to modify the code the following way:

var desiredAppointments = Appointments.Where(a => (a as Appointment).Resources.Any(r => !r.DisplayName.Equals("-") && r.DisplayName == resource.DisplayName));

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ScheduleView
Asked by
ITA
Top achievements
Rank 1
Answers by
Kalin
Telerik team
ITA
Top achievements
Rank 1
Share this question
or