Determine the type of SelectedSlot

5 posts, 0 answers
  1. Brendan
    Brendan avatar
    7 posts
    Member since:
    May 2009

    Posted 18 Jan 2012 Link to this post

    Hi.

    Is there a way to determine the type of the SelectedSlot property on the RadScheduleView control?

    I've got a DayView definition setup on my ScheduleView.

    I've created a class called LunchSlot inherited from the base type of Slot. This class has some extra properties associated with it.

    When I'm loading the appointment data for the Schedule control I also load the lunch definition for a resource, for example Lunch has a recurrence pattern from 1pm - 2pm every day. So I create my LunchSlot object with this recurrence pattern, add it to a collection and bind it to the SpecialSlotsSource of the ScheduleView.

    The Lunch slots show up in the scheduleview all ok with the default gray colour.

    During the AppointmentCreating event I want to determine if the SelectedSlot is now a LunchSlot or just a regular Slot. Is there any way to do this?

    If I double click on a slot between 1pm - 2pm, the SelectedSlot property only seems to return a type of Slot and I have no way to determine if this was a Special slot or just a normal slot.

    I still want the user to be able to create an appointment on a special slot (as it's not marked as ReadOnly), but I want to prompt the user for confirmation that they are about to create an appointment on a special slot before proceeding.

  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jan 2012 Link to this post

    Hello Brendan,

    You cannot directly get the custom slot in AppointmentCreating event handler,  I would suggest to use the Slot's IntersectsWith method to find the correct slot.

    I've attached a simple example to demonstrate the needed approach, please download the attachment and give it a try.  Note how Copy and CopyFrom methods of the LunchSlot class are implemented.

    Kind regards,
    Yana
    the Telerik team

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

  3. DevCraft banner
  4. Brendan
    Brendan avatar
    7 posts
    Member since:
    May 2009

    Posted 24 Jan 2012 Link to this post

    Hi Yana,

    Thanks for the sample, however using the example, no matter what slot I double click on now it thinks that it is of the type LunchSlot.
    I added this line to the example:

    if (lunchSlot != null)
    {
        var customProp = lunchSlot.CustomProperty;
        MessageBox.Show("Lunch Slot Selected");
    }

    And double clicking on any slot will show the message box, even if it's not a special slot.
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 27 Jan 2012 Link to this post

    Hi Brendan,

    You are right, I've found the reason for this issue but will need some additional time to fix it. I will write here as soon as it's ready.

    Kind regards,
    Yana
    the Telerik team

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

  6. paolo30Rose
    paolo30Rose avatar
    3 posts
    Member since:
    Sep 2011

    Posted 08 Jan 2013 Link to this post

    The workaround is:
    Create specialslotStyleSelector like this:

    public class SpecialSlotStyleSelector : ScheduleViewStyleSelector

    {

     

    public Style OtherStyle { get; set; }

     

    public override Style SelectStyle(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)

    {

     

    if (item is SlotScheduler)

    {

     

    SlotScheduler slot = item as SlotScheduler;

    container.SetValue(

     

    HighlightItem.TagProperty, slot); //Set on tag of HighlightItem the custom Special slot

    }

     

    if (OtherStyle != null)

     

    return OtherStyle;

    }

     

    return base.SelectStyle(item, container, activeViewDefinition);

    }

    into XAML create this resource so on tag of border we have the custom special slot :)
    <Style x:Key="OtherStyle1" TargetType="telerik:HighlightItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}" MouseLeftButtonDown="Border_MouseLeftButtonDown" Tag="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Tag}"  >
                                <Border.ToolTip>
                                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ToolTip}"/>
                                </Border.ToolTip>
                                <Image Source="/FOX.Themes;component/Images/ELEMENTS/ico-info-on-16.png" Width="16" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

Back to Top
DevCraft banner