Change appointment element height

9 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Sep 2010

    Posted 24 Jul 2012 Link to this post

    Is it possible to change the height of appointments in the schedulers timeline view?

    Either a fixed size or a "fill" option - where the appointment would fill the day/resource cell- would be great. In the case of the fill option, multiple appointments would divide available space between them until such time as the text becomes unreadable, then they scroll.

    If either of these options are possible, can someone please point me in the right direction so I can implement it on my control?

    Thanks,
    Karl
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 25 Jul 2012 Link to this post

    Hello Karl,

    Thank you for your question.

    There is an AppointmentHeight property in the SchedulerTimelineViewElement which you can use to set fixed height for all appointments. You can set this property in the VisualStyleBuilder as it is demonstrated on the attached screenshot. In case you want to dynamically calculate the value of this property, you can also set it via the following code:
    SchedulerTimelineViewElement timeline = this.radScheduler1.SchedulerElement.ViewElement as SchedulerTimelineViewElement;
    if (timeline != null)
    {
        timeline.AppointmentHeight = value;
    }

    I hope you find this useful. Feel free to ask if you have any additional questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. David
    David avatar
    6 posts
    Member since:
    Oct 2015

    Posted 17 Nov 2015 in reply to Ivan Todorov Link to this post

    Is there a way to set the AppointmentHeight in GroupedByResource mode when in TimeLineView ?

    Because when using the code above, SchedulerTimelineViewElement returns null.

    Here's the code I'm using :


     

    01.For i = 0 To pDataSetRessources.Count - 1
    02.   Dim lMachine As New Resource()
    03.   lMachine.Id = New EventId(pDataSetRessources.Item(i).Id)
    04.   lMachine.Name = pDataSetRessources.Item(i).Nom
    05.   lMachine.Color = If(i Mod 2 = 0, Color.White, Color.Gray)
    06. 
    07.   Me.RadScheduler_PlanningOf.Resources.Add(lMachine)
    08.Next
    09. 
    10.RadScheduler_PlanningOf.GroupType = GroupType.Resource
    11. 
    12. 
    13. 
    14.Me.RadScheduler_PlanningOf.ActiveViewType = SchedulerViewType.Timeline
    15. 
    16.       
    17.           Dim timelineViewElement As SchedulerTimelineViewElement = _
    18.              TryCast(Me.RadScheduler_PlanningOf.SchedulerElement.ViewElement, _
    19.                  SchedulerTimelineViewElement)
    20.            
    21.           If Not IsNothing(timelineViewElement) Then ' Returns nothing :'(
    22.               'No Way
    23.               timelineViewElement.AppointmentHeight = 200
    24.               'If Only ...
    25.               timelineViewElement.Presenter.AppointmentHeight = 200
    26.           End If

     

     

    P.S. I've seen there's classes dedicated to GroupedByResource that might help like
    SchedulerDayViewGroupedByResourceElement > SchedulerDayViewElement
    But no such class for TimeLineView

  4. Dess
    Admin
    Dess avatar
    1998 posts

    Posted 20 Nov 2015 Link to this post

    Hello David,

    Thank you for writing.

    Here is a sample code snippet demonstrating how to specify the AppointmentHeight property for each SchedulerTimelineViewElement associated with a resource: 
    Sub New()
        InitializeComponent()
        Dim colors() As Color = {Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange}
        Dim names() As String = {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"}
        For i As Integer = 0 To names.Length - 1
            Dim resource As New Telerik.WinControls.UI.Resource()
            resource.Id = New EventId(i)
            resource.Name = names(i)
            resource.Color = colors(i)
            Me.RadScheduler1.Resources.Add(resource)
        Next i
        Me.RadScheduler1.GroupType = GroupType.Resource
        Me.RadScheduler1.ActiveView.ResourcesPerView = Me.RadScheduler1.Resources.Count
        Me.RadScheduler1.ActiveViewType = SchedulerViewType.Timeline
        Dim rand As New Random
        For index = 1 To 10
            Dim a As New Appointment(DateTime.Now.AddHours(index), TimeSpan.FromHours(2), "A" & index)
            a.ResourceId = Me.RadScheduler1.Resources(rand.Next(0, Me.RadScheduler1.Resources.Count)).Id
            Me.RadScheduler1.Appointments.Add(a)
        Next
     
        Dim timelineElement As TimelineGroupingByResourcesElement = TryCast(Me.RadScheduler1.SchedulerElement.ViewElement, TimelineGroupingByResourcesElement)
        For Each el As RadElement In timelineElement.Children
            Dim t As SchedulerTimelineViewElement = TryCast(el, SchedulerTimelineViewElement)
            If t IsNot Nothing Then
                t.AppointmentHeight = 50
            End If
        Next
    End Sub

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. David
    David avatar
    6 posts
    Member since:
    Oct 2015

    Posted 24 Nov 2015 in reply to Dess Link to this post

    It works perfectly, thanks a lot.
  6. Andrzej
    Andrzej avatar
    2 posts
    Member since:
    Jul 2013

    Posted 16 Mar in reply to Dess Link to this post

    It's possible to have different AppoitmentHeight for the same view ? In first group I want for example to have A2 with 50 points, A3 with 100 points, A4 with 75points of height etc.
  7. Dess
    Admin
    Dess avatar
    1998 posts

    Posted 17 Mar Link to this post

    Hello Andrzej,

    Thank you for writing.  

    The AppointmentHeight property controls the height for all appointments into the view. However, if you need to achieve different height for the appointments, it is necessary to set the RadScheduler.AutoSizeAppointments property to true and handle the AppointmentFormatting event where you can specify the AppointmentElement.MinSize property. Here is a sample code snippet:
    Me.RadScheduler1.AutoSizeAppointments = True

    Private Sub AppointmentFormatting(sender As Object, e As SchedulerAppointmentEventArgs)
        If e.Appointment.Summary.Contains("1") Then
            e.AppointmentElement.MinSize = New Size(0, 150)
        Else
            e.AppointmentElement.MinSize = New Size(0, 50)
        End If
    End Sub

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Andrzej
    Andrzej avatar
    2 posts
    Member since:
    Jul 2013

    Posted 19 Mar in reply to Dess Link to this post

    Thanks :) It works exactly as I need. Now I can show in 2 ways time consumption by resources (for example field-workers).

    1) in horizontal level -  Me.RadScheduler1.EnableExactTimeRendering = True

    2) in vertical level - via formating height of appointment

    Now RadScheduler shows power. I must try its performance with "big data" - 20/50k of records.

  9. Dess
    Admin
    Dess avatar
    1998 posts

    Posted 22 Mar Link to this post

    Hello Andrzej, 

    Thank you for writing back. 

    I am glad that the provided solution suits your scenario. You can deal with a large number of appointments grouped by resources. Note that for a better visual representation and due to performance consideration it is recommended to show not all resources at a time by a subset of them by setting the RadScheduler.ActiveView.ResourcesPerView property to an appropriate value. Additional information about RadScheduler's resources is available in the following help article: http://docs.telerik.com/devtools/winforms/scheduler/views/grouping-by-resources

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top