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

Show Appointment Dialog Using Code Behind

16 Answers 279 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Moe
Top achievements
Rank 1
Moe asked on 26 Mar 2012, 06:57 AM
I know you can double click the ScheduleView and show the add/edit appointment dialog, is it possible to show it using code behind (C#)?

16 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 28 Mar 2012, 11:38 AM
Hello Mohamed,

In order to show the EditAppointmentDialog you can execute the EditAppointment Command of the ScheduleView, for example:

RadScheduleViewCommands.EditAppointment.Execute(appointment, this.scheduleView);

Where appointment is the newly created appointment.

Regards,
Konstantina
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
ITA
Top achievements
Rank 1
answered on 20 Apr 2012, 03:17 PM
Hi,

but is it possible to show the Appointment Dialog from somewhere else? I have my SchduleView on my Schedule.xaml Page. Somewhere else in my application i want to open the Appointment Dialog.

Is that possible and how?

thanks a lot
Regads
rene
0
Konstantina
Telerik team
answered on 24 Apr 2012, 02:20 PM
Hello Rene,

If you have a reference to the ScheduleView and you give that reference to the Command, you should be able to open the dialog from somewhere else.

Regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
ITA
Top achievements
Rank 1
answered on 25 Apr 2012, 09:13 AM
Hi,

but how do i set the reference to my scheduleview? Now i use this code to open the appointment (i try).

private void test_Click(object sender, RoutedEventArgs e)
    {
        RadScheduleView RSvD = new RadScheduleView();
        Appointment appoint = new Appointment();
        RadScheduleViewCommands.EditAppointment.Execute(appoint, RSvD);
   }

But i just get an empty box (attached).

Thanks
rene
0
Mace
Top achievements
Rank 1
answered on 14 May 2012, 09:31 AM
Hi, i'm in the same situation, i create an appointment with the code behind with this code:
RadScheduleView MyRadScheduleView = (sender as RadScheduleView);
Appointment appointment = new Appointment();
appointment.Subject = "New Appointment";
appointment.Start = MyRadScheduleView.SelectedSlot.Start;
appointment.End = MyRadScheduleView.SelectedSlot.End;                               
foreach (Resource r in MyRadScheduleView.SelectedSlot.Resources.AsEnumerable())
{                    
appointment.Resources.Add(r);                    
}                
RadScheduleViewCommands.CreateAppointment.Execute(appointment, MyRadScheduleView);


But when the EditAppointmentDialog appear, there is no resources selected, how i can selected resources?

Thanks
Gat
0
ITA
Top achievements
Rank 1
answered on 14 May 2012, 10:47 AM
Hi Gat,

my problem ist, the appointment does not appear?!

Thanks
Rene
0
Konstantina
Telerik team
answered on 17 May 2012, 07:43 AM
Hello,

Gat, could you please explain on which event you are adding the new appointment?
Also, if you could give us some more details about the scenarios in which you experience the issue will be much helpful for tracking down the source of the issue. Sending us a sample application in which is illustrated your approaches and what you need to achieve will help us in providing you with solution in a timely manner.

Looking forward to your replies.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
ITA
Top achievements
Rank 1
answered on 17 May 2012, 09:56 AM
Hi,

it's quiet simple. I want to open the appointment dialog from somewhere in my project. Perhaps after cklicking a button.
 
That's it!

Thanks
Best Regards
Rene
0
Konstantina
Telerik team
answered on 22 May 2012, 09:30 AM
Hi Rene,

As mentioned earlier, if you have a reference to the ScheduleView and you give that reference to the Command, you should be able to open the dialog from somewhere else.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Mace
Top achievements
Rank 1
answered on 22 May 2012, 12:44 PM
Hello Konstantina,

I want create a new Custom Appointment after the user has selected a time slot at the Mouse_Up Event, my scheduleView call this method:

private void ScheduleView_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {            
            if (sender is RadScheduleView)
            {
                RadScheduleView MyRadScheduleView = (sender as RadScheduleView);


                MyAppointment appointment = new MyAppointment
                                              {
                                                  Subject = "New Appointment",
                                                  Start = MyRadScheduleView.SelectedSlot.Start,
                                                  End = MyRadScheduleView.SelectedSlot.End
                                              };
                foreach (Resource r in MyRadScheduleView.SelectedSlot.Resources.AsEnumerable())
                {                    
                    appointment.Resources.Add(r);                    
                }                
                RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(appointment, MyRadScheduleView);                
            }
        }


But when the CreateAppointmentDialog appear, the ressource is not selected then my appointment then ressources.
I just want my ressources are selected in the CreateAppointmentDialog.
 
0
ITA
Top achievements
Rank 1
answered on 22 May 2012, 03:21 PM
Hi,

something like this:

Telerik.Windows.Controls.RadScheduleView MyView = new Telerik.Windows.Controls.RadScheduleView();  
Telerik.Windows.Controls.RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(null, MyView);

Thanks
rene
0
Yana
Telerik team
answered on 24 May 2012, 02:33 PM
Hello all,

# to Mace:

CreateAppointment command expects the first parameter to be of type IDateSpan ( like Slot, for example) - that is why neither of the properties are not set in the dialog. I suggest to call the command like this:

RadScheduleViewCommands.CreateAppointmentWithDialog.Execute(MyRadScheduleView.SelectedSlot, MyRadScheduleView);

and subscribe to AppointmentCreating event and set the Subject of the new appointment in its handler:

private void ScheduleView_AppointmentCreating(object sender, AppointmentCreatingEventArgs e)
{
    e.Appointment.Subject = "New Appointment";
}

in this way the resources will be set without a problem.

#to Rene:

As explained earlier you should set the ScheduleView as a second parameter when using the command. But note that it should be the ScheduleView instance which is placed on the page, not a newly created one.

Hope this helps.

Greetings,
Yana
the Telerik team

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

0
Karthik
Top achievements
Rank 1
answered on 04 May 2016, 05:08 AM

Hello,

When i double on the ScheduleView, I want to get the details which was entering in an appointment. Mean to say i wanna store it locally(DB). How to achieve it??

If any examples are there please share me, it may help me to solve this.

 

0
Kalin
Telerik team
answered on 05 May 2016, 09:23 AM
Hi Karthik,

Can you please share some more details regarding the desired scenario? Where on the control you want to click? And which appointment exactly you need to get details for? If you mean when double clicking an Appointment, then you could hook to the ShowDialog event of RadScheduleView and extract the currently clicked Appointment from the event arguments.

Hope this helps.

Regards,
Kalin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Karthik
Top achievements
Rank 1
answered on 05 May 2016, 09:34 AM

Hello Kalin,

Thanks for the reply. Gone through the ShowDialog and getting the details, but how to achieve it using MVVM architecture, Specifically when ShowDialog opens i wanna save Appointment details to my DB, but i couldn't able to recognize which event is firing. Even i have tried RadScheduleView_AppointmentCreated ,whether it is the correct method or wrong?? If yes, then can we do using MVVM??

 

Thank You :)

0
Kalin
Telerik team
answered on 09 May 2016, 08:36 AM
Hi Karthik,

Through the arguments of the event (the ViewMode property of the AppointmentDialogViewModel) you can find out if the dialog is opening for creating a new appointment or for editing an existing one. Please check the following snippet:

private void radScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
{
    var isAddingNew = (e.DialogViewModel as AppointmentDialogViewModel).ViewMode == AppointmentViewMode.Add;
}

You could use our EventToCommand behavior in order to execute a command in the ViewModel whenever the event is fired.

Hope this helps.

Regards,
Kalin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ScheduleView
Asked by
Moe
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
ITA
Top achievements
Rank 1
Mace
Top achievements
Rank 1
Yana
Telerik team
Karthik
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or