update UI after collection of Appointment change

13 posts, 0 answers
  1. Lucie
    Lucie avatar
    28 posts
    Member since:
    Jun 2011

    Posted 18 Jan 2012 Link to this post

    I have control derived from ScheduleView and collection of custom Appointments filled programmatically and assigned to AppointmentSource.

     

    private ObservableCollection<CalendarDataItem> calendardataitems = new ObservableCollection<CalendarDataItem>();
    . . .

     

     

     

    this.AppointmentsSource = calendardataitems;

     

    Appointments are visible in ScheduleView and show expected data.

     

    When I change appointment’s property in collection then changes are not visible in ScheduleView.

    I use my custom form for editing of Appointments. Form is used on other places of application so is not possible to derive it from dialog included in ScheduleView.

     

    I think that I should call a method from ScheduleView to refresh view but I do not know what method.

     

    Can you help me?

     

  2. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 18 Jan 2012 Link to this post

    Hi,

    Please read our article how to edit appointments programmatically here.
    If you still need to edit appointment in the calendardataitems collection directly I suggest you after editing to remove the appointment and add it again to the collection.This should reset the view.

    Regards,
    Rosi
    the Telerik team

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

  3. DevCraft banner
  4. Lucie
    Lucie avatar
    28 posts
    Member since:
    Jun 2011

    Posted 19 Jan 2012 Link to this post

    I am sorry your link to sample is wrong. Can you correct it?

    I have done some test with removing and adding appointment to collection and also I have tried to set AppointmentsSource to null
    and again to calendardataitems. I can  see changes but I have problem with SelectedAppointment and when I have slot expanded to see many appointments then it is collapsed after reassign AppointmentsSource.

    I still think that there should be method for redraw of content of ScheduleView.

    Thank you for answer
  5. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 19 Jan 2012 Link to this post

    Hi,

    I am sorry for the incorrect link,the correct one is posted below:
    http://www.telerik.com/help/silverlight/radscheduleview-end-user-capabilities-edit-appointment.html
    Also, I suggest you not reset the whole AppointmentsSource, but remove and add only the edited item:

    something like:
    var itemToEdit =calendaritems.Firts();
    calendaritems.Remove(itemToEdit);
    calendaritems.Add(itemToEdit);

    All the best,
    Rosi
    the Telerik team

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

  6. Andris
    Andris avatar
    1 posts
    Member since:
    Sep 2012

    Posted 05 Sep 2012 Link to this post

    Hi Rosi,

    I'm currently study Telerik controls with idea to buy them.
    And I actually disappointed with your answer.

    What about normal MVVM approach?
    Why Schedule view do not track changes in AppointmentsSource (this is possible since source is ObservableCollection and Appointments impement INotifyPropertyChanged)?
    It is normally to change things in ViewModel and expect UI to be automatically refresh without additional Voodoo magic.

    In my particular case, I have undesired side effects when Add/Remove Appointments 
    (additional calls to server in other logic of view model).
    Is Add/Remove really only option for refresh ScheduleView from ViewModel?

    Regards,
    Andris
  7. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 06 Sep 2012 Link to this post

    Hello Andris,

    Due to some internal logic into the Appointment class the best way to achieve this is to use the RadScheduleView's BeginEdit and Commit methods. I believe this will not cause any additional calls to the server.
    Another tricky way to update the RadScheduleView from the ViewModel would be to bind TwoWay its ActiveViewDefinitionIndex property. When this property changes the RadScheduleView will be updated.

    Greetings,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Justin
    Justin avatar
    2 posts
    Member since:
    Jun 2014

    Posted 20 Nov 2014 Link to this post

    Hi Team,

    My situation is slightly similar.
    But I need to refresh my entire appointments source.

    In essense, the user will have multiple 'calendars'.
    So when they select Calendar 1, they can view/edit/filter all the appointments (and appointment types) for Calendar 1.
    And then when they select Calendar 2, the ObservableCollection of appointments will change entirely.

    But the ScheduleView is not being updated/refreshed.
    And i have tried all the methods mentioned above.
    I'm using purely MVVM.

    How would I update the view?

    Regards and Thanks,
    Justin 
  9. Justin
    Justin avatar
    2 posts
    Member since:
    Jun 2014

    Posted 20 Nov 2014 in reply to Justin Link to this post

    Oh yes, forgot to add that i'm using Telerik UI for WPF
  10. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 20 Nov 2014 Link to this post

    Hi Justin,

    I noticed you have opened a support ticket regarding the same questions. I have already replied you there - can you please check my answer and let me know if it helps. I'll also copy my reply here:

    If you reset the property bound to AppointmentsSource of the control (set new collection to the property) you would need to raise property changed in order to notify the UI that the property is changed. If you just clear the collection everything should work as expected.

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  11. guillaume rousseau
    guillaume rousseau avatar
    2 posts
    Member since:
    Sep 2009

    Posted 09 Feb in reply to Kalin Link to this post

    Hello,

    When rebinding the AppointementsSource the scroll bar is reset to the top, I did try to find a way to avoid that behavior but with no success any clue about that ?

     

  12. guillaume rousseau
    guillaume rousseau avatar
    2 posts
    Member since:
    Sep 2009

    Posted 09 Feb in reply to guillaume rousseau Link to this post

    even with RetainScrollPosition="True" in the xaml, it reset the scroll bar to top
  13. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 12 Feb Link to this post

    Hi Guillaume,

    By design the scroll is being reset if the AppointmentsSource is set to null even the RetainScrollPosition is set to True - so I assume you set it null first and then to the new collection. What I can suggest you would be to try not setting it null and see if this helps (the RetainScrollPosition property should be True). However if this doesn't help - I would like to ask you to share some sample code reproducing the observed behavior, so we can check it on our side.

    Hope this will work for you.

    Regards,
    Kalin
    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
  14. Karthik
    Karthik avatar
    10 posts
    Member since:
    Apr 2016

    Posted 07 Jun Link to this post

    Hello,

    My UI not updating but it shoes the records in ViewModel.

    I'm using 

    protected override DateTime GetVisibleRangeStart(DateTime currentDate, System.Globalization.CultureInfo culture, DayOfWeek? firstDayOfWeek)   to get the current date and fetching the events(Appointments) from my DB, but i can't able to refresh or stick it to the SchedulerView.

    I have raised the property changed in order to notify the UI but no any effect.

    Please help me out to get it solved.

Back to Top
DevCraft banner