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

Determine the type of SelectedSlot

4 Answers 91 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 18 Jan 2012, 01:45 PM

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.

4 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Jan 2012, 01:00 PM
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 >>

0
Brendan
Top achievements
Rank 1
answered on 24 Jan 2012, 01:23 PM
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.
0
Yana
Telerik team
answered on 27 Jan 2012, 08:40 AM
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 >>

0
paolo30Rose
Top achievements
Rank 1
answered on 08 Jan 2013, 04:57 PM
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>

Tags
ScheduleView
Asked by
Brendan
Top achievements
Rank 1
Answers by
Yana
Telerik team
Brendan
Top achievements
Rank 1
paolo30Rose
Top achievements
Rank 1
Share this question
or