AppointmentDialogViewModel constructor

11 posts, 0 answers
  1. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 18 Aug 2011 Link to this post

    I need to extend this AppointmentDialogViewModel class so that I can get some extra data in there for the appointment edit screen.  I've tried just creating a new VM and overriding it, but it causes significant trouble.  So I thought I would just create a VM with AppointmentDialogViewModel as it's base.  Unfortunately, I need to get the Occurrence object to pass to the constructor and I see no way to do this.

    Just as a background, I've attempted almost every suggestion on these forums for overriding the AppointmentDialogViewModel for the appointment edit screen and nothing has worked fully for my needs.  I'm trying to adhere to MVVM, and that might be my mistake.  At this point, either I get this to work, or I revert to handling the AppointmentEditing event in code and manually doing what I need there, but I would like to take advantage of how you guys have already handled the appointment editing.

    I'm basically building the appointment edit screen from scratch, and I have drop downs that I need to populate.  The data for those drop downs are in the ScheduleView.DataContext, but I can't find how to get that data into the AppointmentDialogViewModel so the appointment window will see it.  That's why I figured I could use it as a base for my view model and all I needed to add was the data for the drop downs.  If there is a better way, please let me know.  Otherwise, can you tell me how to get the Occurrence object so the constructor would work?

    Thanks!
  2. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 19 Aug 2011 Link to this post

    I found the solution to this problem.

    base(Occurrence.CreateOccurrence((CustomAppointment)scheduleView.SelectedAppointment, scheduleView.SelectedAppointment.Start, scheduleView.SelectedAppointment.End), AppointmentViewMode.Edit, host, (IEnumerable<IResourceType>)scheduleView.ResourceTypesSource, (IEnumerable<ITimeMarker>)scheduleView.TimeMarkersSource, categoryList)

    I used this call to the base constructor.  It seems to be working really well, I don't need to recreate the code from AppointmentDialogViewModel when I use this approach and I can have my own properties for the Appointment Dialog View Model.
  3. DevCraft banner
  4. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 24 Aug 2011 Link to this post

    Unfortunately, I have found that my solution doesn't work as well as I hoped.

    The problem I'm having now is that the AppointmentEdited and AppointmentCreated events aren't getting fired when the Appointment Dialog is confirmed.  Instead, it only fires when I go to edit another appointment.  This is a problem since my changes aren't getting saved to the database and the view isn't being updated with the changes until I go to change the date or edit another appointment.

    This works fine if I drag and drop, or if I stop using the DialogHostFactory.  Unfortunately, I can't assign my custom AppointmentDialogViewModel if I don't use the DialogHostFactory.

    Is there something not obvious I need to do with the confirm of the AppoinmentDialog to make sure the AppointmentEdited event gets fired?  I've tried calling Occurrence.Appointment.EndEdit() and that doesn't trigger it either.  So there is something not obvious that I need to do.  Please help, this is a major problem for me now.

  5. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 30 Aug 2011 Link to this post

    Hello Michael ,

    I suggest you not to inherit and replace the AppointmentDialogViewModel with your custom view model, but
    using it internally to complete the task. Please find the project attached for more details.

    Regards,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 30 Aug 2011 Link to this post

    That was one of the approaches I tried before this one.  It just doesn't do what I need it to.

    I found a fix, it isn't pretty but my stuff is working now.

    I would like to request that a future version would allow us to extend the AppointmentDialogViewModel class without breaking a lot of stuff.
  7. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 31 Aug 2011 Link to this post

    Hello Michael,

    We are glad that you resolve the issue yourself.

    We will consider extending the view model of the RadScheduleView dialogs. One thing that we are considering is adding a new property of type object to the AppointmentDialogViewModel class. Then in the event handler of the ShowDialog event you will have the ability to set an instance of your class to this property and bind to it in the dialog. Does this sound useful to you? We will be glad to hear your opinion.


    Regards,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  8. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 31 Aug 2011 Link to this post

    Honestly, I'm not sure.

    Like I mentioned in my original post, I have a few combo boxes for an appointment that aren't really resources.  Those drop downs are populated by a set of collections that I populate in my ScheduleView view model.  I don't need the whole VM, but with the object implementation, I think that's what I would need to do, assign the ScheduleView view model to the object property.  I'm just not sure how binding the combo boxes would work out at that point.

    I think just being able to use AppointmentDialogViewModel as a base class would be the most flexible solution.

    I've seen others on the board request the same kind of capability, hopefully they will see this post and post their feelings.
  9. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 02 Sep 2011 Link to this post

    Hi Michael,

    Extending the dialog ViewModel to be inherited requires a lot of changes in RadScheduleView control.That is why we have plans to introduce the mechanism that I described in the previous message for the upcoming Service Pack next month.

    I will try to explain it once again with an example:

    In the AppointmentDialogViewModel we have plans to add new property similar to:

    private object additonalData;
    public
    object AdditionalData
    {
      get
      {
        return additonalData;
       }
      set
      {
         additionalData = value;
         OnPropertyChange("AdditionalData");
      }
    }

    Then In the ShowDialog event you will have the ability to set the all additional data that you need to be displayed in the dialog like:
    public class MyData
    {
      public IEnumerable <object>ComboItemsSource
      {
           get;
           set;
       }
    }
    public void ShowDialog (object sender, ShowDialogEventArgs args)
    {
       e.ViewModel.AdditionalData= new MyData();
     
    }

    and the binding in the template of the edit dialog will be something like:

    <telerik:RadComboBox ItemsSource="{Binding AdditionalData.ComboItemsSource}"/>


    If this mechanism does not met the requirements of most common scenarios we will consider changing the logic for the major Q3 2011 release.

    Greetings,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  10. Michael Lilly
    Michael Lilly avatar
    53 posts
    Member since:
    Apr 2010

    Posted 02 Sep 2011 Link to this post

    Yeah, that sounds like it would work for me.

    Thanks!
  11. Tessa
    Tessa avatar
    8 posts
    Member since:
    Jul 2011

    Posted 28 Feb 2012 Link to this post

    Hi Rosi,

    Please can you confirm if the "AdditionalData" property has been added to the ScheduleView control?

    If it has, please can you send details of how it works.

    Thanks
    Tessa
  12. Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 02 Mar 2012 Link to this post

    Hello,

    The feature does not come out-of-the-box in the current version. We’re considering your request, however, we started a major undertaking several months ago and we had to relocate the resources for that new initiative – the GanttView control. We will do our best to include it for the upcoming service pack by the end of March. Please,excuse us once again for misleading you.

    Regards,
    Rosi
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner