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

RadScheduleView with GroupDescriptions and ShowAllDayArea

1 Answer 175 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Luke
Top achievements
Rank 1
Luke asked on 14 Aug 2012, 07:53 AM
I have been working on a form with the RadScheduleView and noticed that the AllDayEvent area at the top disappeared at some point in my development. I realised that by adding a ResourceGroupDescription to the GroupDescriptionCollection, the AllDayEvent area disappears even though the ViewDefinition still has the ShowAllDayArea attribute as "True".

Is this a bug? Is there a way I can group my appointments and still have all day appointments at the top? This is an essential feature for our product.

Below is simplified code which demonstrates the issue:
(I wanted to attach a zip with the project but it only allowed me to attach image files)

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Controls:RadButton Content="{Binding ButtonText}" Command="{Binding ToggleCommand}" Height="50" />
    <telerik:RadScheduleView Grid.Row="1"
            AppointmentsSource="{Binding Appointments}"
            ResourceTypesSource="{Binding ResourceTypes}"
            GroupDescriptionsSource="{Binding GroupDescriptions}">
        <telerik:RadScheduleView.ViewDefinitions>
            <telerik:WeekViewDefinition ShowAllDayArea="True" MinTimeRulerExtent="1" />
            <telerik:DayViewDefinition ShowAllDayArea="True" MinTimeRulerExtent="1" />
        </telerik:RadScheduleView.ViewDefinitions>
    </telerik:RadScheduleView>
</Grid>

public class MainViewModel : ViewModelBase
{
    private readonly ResourceGroupDescription _resourceGroupDescription;
    private bool _showGroupDescription;
 
    public MainViewModel()
    {
        ToggleCommand = new RelayCommand(Toggle);
        _resourceGroupDescription = new ResourceGroupDescription {ResourceType = "Staff"};
        GroupDescriptions = new GroupDescriptionCollection {new DateGroupDescription()};
        ResourceTypes = new ObservableCollection<ResourceType> {new ResourceType("Staff") {Resources = {new Resource("John"), new Resource("Mark")}}};
        Appointments = new ObservableCollection<IAppointment>();
 
        Toggle();
 
        // populate test appointments
        for (var i = -7; i < 7; i++)
        {
            var date = DateTime.Today.AddDays(i).Add(new TimeSpan(9, 30, 0));
            var isAllDay = i%3 == 0;
            var resourceName = i % 2 == 0 ? "John" : "Mark";
            var subject = resourceName + (isAllDay ? " All Day Event" : " Appointment");
            Appointments.Add(new Appointment
                                 {
                                     Start = date,
                                     End = date.AddHours(8),
                                     Subject = subject,
                                     IsAllDayEvent = isAllDay,
                                     Resources = {new Resource(resourceName, "Staff")}
                                 });
        }
    }
 
    public ICommand ToggleCommand { get; private set; }
    public ObservableCollection<IAppointment> Appointments { get; private set; }
    public GroupDescriptionCollection GroupDescriptions { get; private set; }
    public ObservableCollection<ResourceType> ResourceTypes { get; private set; }
 
    private string _buttonText;
    public string ButtonText
    {
        get { return _buttonText; }
        set { Set(() => ButtonText, ref _buttonText, value); }
    }
 
    private void Toggle()
    {
        _showGroupDescription = !_showGroupDescription;
        if (_showGroupDescription)
        {
            GroupDescriptions.Add(_resourceGroupDescription);
            ButtonText = "Remove Group Description";
        }
        else
        {
            GroupDescriptions.Remove(_resourceGroupDescription);
            ButtonText = "Show Group Description";
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Boyan
Telerik team
answered on 16 Aug 2012, 08:51 AM
Hi Luke,

There is a limitation of the control that you can show all day area only when the DateGroupDescription is the last in GroupDescriptionCollection. So if you want the AllDayArea to be visible you have to change the following code:
private void Toggle()
{
    _showGroupDescription = !_showGroupDescription;
    if (_showGroupDescription)
    {
        GroupDescriptions.Insert(0, _resourceGroupDescription);

Hope this helps.

All the best,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Luke
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Share this question
or