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

Combobox/Custom Field in Edit Appointment Dialog

5 Answers 100 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 06 Mar 2013, 08:20 PM
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?




5 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 06 Mar 2013, 08:44 PM
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


0
Tim
Top achievements
Rank 1
answered on 07 Mar 2013, 12:56 AM
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?





0
Yana
Telerik team
answered on 08 Mar 2013, 08:44 AM
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.

0
mike okon
Top achievements
Rank 1
answered on 15 May 2013, 03:51 PM
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
0
Yana
Telerik team
answered on 20 May 2013, 07:47 AM
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.

Tags
ScheduleView
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Yana
Telerik team
mike okon
Top achievements
Rank 1
Share this question
or