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

Appointment Start/End updated from VM

9 Answers 140 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Cameron
Top achievements
Rank 1
Cameron asked on 14 Aug 2015, 02:47 PM

Hey,

 I have a button that changes my appointment start and end times between UTC and Local to a slected Timezone. The button updates the appointments correctly but I cannot get the UI to update accordingly. I have noticed that a forum post from two years ago address' this problem but it did not look like a solution was found as I too am using MVVM. 

Any suggestions?

 Thanks,

Cameron

9 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 17 Aug 2015, 07:01 AM
Hi,

I suggest you edit the appointment's properties using the BeiginEdit() and Commit() methods as described in our documentation.


Another way to refresh the UI is by resetting the template as follows:
System.Windows.Controls.ControlTemplate template = this.ScheduleView.Template;
  this.ScheduleView.Template = null;
  this.ScheduleView.Template = template;

Hope this helps.

Regards,
Rosi
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Cameron
Top achievements
Rank 1
answered on 17 Aug 2015, 10:07 AM

Hey, 

 Thanks for that. Can I ask, why do the Appointments not update when I change the Start and Finish time in my viewmodel? I basically set the new Start and Finish time and call and OnPropertyChanged event against the observable collection but it does not update.

 Thanks

Cameron

0
Rosi
Telerik team
answered on 20 Aug 2015, 06:36 AM
Hello,

Appointment class uses an internal backup storage used for canceling the edit of the properties and implement IEditableObject interface. That is why you need to call the Commit method in order to update the default values of the appointment class.


If you implement a custom appointment and add regular Dependency properties for example  CustomStart and CustomEnd and use them in the template changing them on propertychange will affect the UI immediately.

However in this case canceling the change of the property via UI will not be possible.

Regards, Rosi
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Andrey
Top achievements
Rank 1
answered on 01 Feb 2016, 08:33 AM

Hi,

Can you tell a little more about custom CustomStart and CustomEnd properties. Will it instead old (Start/End) properties? And how to use them in template. Maybe you can give an example. Because, as I understood from the posts above, it is not possible to update view (start/end of appointments in scheduler) without direct manipulations with scheduler (BeiginEdit() and Commit()) that is not good solution according to MVVM.

Best regards,
Andrey

0
Rosi
Telerik team
answered on 02 Feb 2016, 12:13 PM
Hello,

Example of custom properties added to appointment and its template can be found here and here
Also please follow our documentation about Custom Appointment for more details.

Hope this helps.

Regards,
Rosi
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Andrey
Top achievements
Rank 1
answered on 03 Feb 2016, 08:23 AM

Hi,

Thank you for the answer. I understood all about custom appointments.

But the main question still remains: is there any way to update start and end of appointments in scheduler in the View without having access to this scheduler? or start and end of the appointment in in scheduler strictly attached to Start / End of IAppointment? I ask this because I do not have access to the View (so I can't use BeginEdit and Commit) and there is a need to update start and end of the appointments in scheduler.

Best regards,
Andrey

0
Rosi
Telerik team
answered on 05 Feb 2016, 12:14 PM
Hello,

Using the BeginEdit() and Commit() methods is the approach that I suggest you to use.
However another thing that you can try is to  update the properties of appointments without calling these methods and try removing the edited appointment and adding it again in the appointments source collection. This should do the trick.

Hope this helps.

Regards,
Rosi
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Cameron
Top achievements
Rank 1
answered on 01 Mar 2016, 10:31 AM

Hey,

Have you made sure that you have implemented the Copy() and CopyFrom() function in your custom appointment class?

public override void CopyFrom(IAppointment other)
{
    AppointmentModel appointment = other as AppointmentModel;
    if (appointment != null)
    {
        this.Start = appointment.Start;
        this.End = appointment.End;
    }
    base.CopyFrom(other);
}

Then by updating the Start and End time of the appointment should refresh on the ScheduleView. 

Regards,

CM

0
Andrey
Top achievements
Rank 1
answered on 06 Apr 2016, 12:04 PM

Thanks a lot for answers. Everything works fine.

Regards,
Andrey

Tags
ScheduleView
Asked by
Cameron
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Cameron
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Share this question
or