Combobox/Custom Field in Edit Appointment Dialog

6 posts, 0 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 06 Mar 2013 Link to this post

    I have custom fields in my Appointment Dialog. I want to change one of the TextBoxes to a ComboBox.

    Here is the section I want to modify that is currently in my Telerik.Windows.Controls.ScheduleView.xaml
    <TextBlock Grid.Row="7" Grid.Column="0" Margin="6" VerticalAlignment="Center" telerik:LocalizationManager.ResourceKey="Reason for reschedule" />
    <TextBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2" Margin="3" IsReadOnly="{Binding IsReadOnly}" Text="{Binding Occurrence.Appointment.RescheduleReason, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" telerik:StyleManager.Theme="{StaticResource Theme}" />


    I want to replace the second textbox with the following:
    <ComboBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2" Margin="3" ItemsSource="{Binding }"

    I want to bind the ItemsSource to an ObservableCollection available in my View Model page. I then want to bind the selected item to Occurrence.Appointment.RescheduleReason much like the current textbox's text is bound to.

    I am having issues accessing the ObservableCollection CancelReasons though. It is set up in my ViewModel as:
    private ObservableCollection<OptionSet> cancelReasons;
    public ObservableCollection<OptionSet> CancelReasons
    {
    get
    {
    return this.cancelReasons;
    }
    private set
    {
    this.cancelReasons = value;
    this.OnPropertyChanged("CancelReasons");
    }
    }


    How can I accomplish this?




  2. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 06 Mar 2013 Link to this post

    Here is a bit more information:

    This is where I am populating my ObservableCollection
    public MainPageViewModel(ILifestyleLiftServiceAgent serviceAgent)
    {
    MscrmSrvc.Service1Client proxy = new Scheduler.MscrmSrvc.Service1Client();
    proxy.GetOptionSetCompleted += new EventHandler<MscrmSrvc.GetOptionSetCompletedEventArgs>(proxy_GetOptionSetCompleted);
    proxy.GetOptionSetAsync("", "myOptionSet");
    }
     
    void proxy_GetOptionSetCompleted(object sender, MscrmSrvc.GetOptionSetCompletedEventArgs e)
    {
       ObservableCollection<Dictionary<string,string>> myList = e.Result;
       ObservableCollection<OptionSet> myOptionSet = new ObservableCollection<OptionSet>();
     
       foreach (Dictionary<string, string> myItem in myList)
       {
          foreach (KeyValuePair<string, string> kvp in myItem)
          {
             OptionSet os = new OptionSet();
             os.Label = kvp.Key;
             os.Value = kvp.Value;
     
             myOptionSet.Add(os);
          }
       }
     
       CancelReasons = myOptionSet;
    }


    My ScheduleView.xaml has this line added to it:
    <ComboBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2" Margin="3" ItemsSource="{Binding CancelReasons}" />

    When I bring up the Appointment dialog, the combobox is empty. It should contain 1 item as I've verfied proxy_GetOptionSetCompleted is called correctly and populates the CancelReasons ObservableCollection.

    Thanks


  3. DevCraft banner
  4. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 06 Mar 2013 Link to this post

    I have further changed my combobox to the following:
    <telerik:RadComboBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="2" Margin="3" ItemsSource="{Binding ElementName=radScheduleView, Path=DataContext.CancelReasons, Mode=TwoWay}" DisplayMemberPath="Label"  />

    Where:
    <telerik:RadScheduleView telerik:StyleManager.Theme="Office_Silver" x:Name="radScheduleView"
                                            Grid.Column="0" Grid.Row="0"

    And my CancelReasons is an ObservableCollection of OptionSet:
    public class OptionSet
        {
            public OptionSet()
            {
     
            }
     
            public OptionSet(string label, string value)
            {
                this.Label = label;
                this.Value = value;
            }
     
            public string Label { get; set; }
            public string Value { get; set; }
        }

    The combobox is still coming up empty even though I see one entry in the CancelReasons.

    Any ideas from here?





  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 Mar 2013 Link to this post

    Hi Tim,

    Please check this help article where it is explained how to add RadComboBox to EditAppointmentDialog and how to bind it to a property in the ViewModel.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 15 May 2013 Link to this post

    Hi

    I have created 2 New Custom Appointment properties as per the Custom Appointment Documentation. My Question Lies How can I Set their value back into the SQLAppointments Table back in the database? I have added 2 extra columns but have no idea how to have the custom appointment properties be written back into the Database

    Can you please provide an example?

    regards
    mike
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 20 May 2013 Link to this post

    Hello Mike,

    Please check our reply at the other thread here.

    I would kindly ask you not to post the same question in different threads as this slows our reply.
    Thank you for the understanding.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner