Event for Slot Selection Change

7 posts, 0 answers
  1. TEC
    TEC avatar
    9 posts
    Member since:
    Aug 2009

    Posted 05 Aug 2011 Link to this post

    Hi,

    Is there an event where that is triggered when the Slot Selection Changes (just like AppointmentSelectionChanged)? Can you illustrate in code a way to hook on to the RadScheduleView Slot Selection Change.

    Kind regards
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 Aug 2011 Link to this post

    Hello,

    RadScheduleView doesn't provide such an event. Could you please give us more details about your scenario and why you need this Slot selection changed event? Thanks

    All the best,
    Yana
    the Telerik team

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

  3. DevCraft banner
  4. TEC
    TEC avatar
    9 posts
    Member since:
    Aug 2009

    Posted 10 Aug 2011 Link to this post

    Hi,

    My scenario is that I want to propose a list of appointments to the user when a slot is selected? The proposal of appointments has to be calculated server side, so I need a hook (event) for the slot selection change to send a command to the server. I hope this is clear enough. 

    Kind regards.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 11 Aug 2011 Link to this post

    Hello Tec,

    You can bind SelectedSlot property of the ScheduleView to a property in your ViewModel like this:

    <telerik:RadScheduleView x:Name="schedule" SelectedSlot="{Binding SelectedSlot, Mode=TwoWay}">
        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:MonthViewDefinition />
        </telerik:RadScheduleView.ViewDefinitions>
    ...
    </telerik:RadScheduleView>

    and the ViewModel:

    public class MyViewModel : ViewModelBase
    {
        private Slot selectedSlot;
        public Slot SelectedSlot
        {
            set
            {
                if (selectedSlot != value)
                {
                    selectedSlot = value;
                    this.OnPropertyChanged("SelectedSlot");
                }
            }
            get
            {
                return selectedSlot;
            }
        }
    }

    Try it and let us know how it goes.

    Regards,
    Yana
    the Telerik team

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

  6. TEC
    TEC avatar
    9 posts
    Member since:
    Aug 2009

    Posted 19 Aug 2011 Link to this post

    Hi,

    I did not do it exactly as you suggested, but I did get it working for me with a binding on the "SelectedSlot" property. As follows:
    ......
       Binding bSelectedSlot = new Binding();
    			bSelectedSlot.Source = myRadScheduleView;
    			bSelectedSlot.Mode = BindingMode.TwoWay;
    			bSelectedSlot.Path = new PropertyPath("SelectedSlot");
    			bSelectedSlot.Converter = new SlotSelectionConverter(SlotSelectionChanged);
       myRadScheduleView.SetBinding(RadScheduleView.SelectedSlotProperty, bSelectedSlot);
    
    .....
      private void SlotSelectionChanged(Slot slot)
    		{
    			......
    		}


        public delegate void ProcessSlotDelegate(Slot slot);
    
        public class SlotSelectionConverter : IValueConverter
        {
            private ProcessSlotDelegate slotSelectionChanged;
     
            public SlotSelectionConverter(ProcessSlotDelegate slotSelectionChanged)
            {
                this.slotSelectionChanged = slotSelectionChanged;
            }
     
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                if ((slotSelectionChanged != null) && (value is Slot))
                    slotSelectionChanged(value as Slot);
                return value;
            }
     
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return value;
            }
        }

    Thanks for the help.

    Kind regards
  7. Eric
    Eric avatar
    5 posts
    Member since:
    Jun 2011

    Posted 23 Aug 2011 Link to this post

    Sorry...didn't scroll down far enough.
  8. Ad
    Ad avatar
    3 posts
    Member since:
    Nov 2014

    Posted 05 Aug 2015 Link to this post

    The first suggestion from Yana works great for me out-of-the-box.

    Thanks anyway.

Back to Top
DevCraft banner