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
13 Answers, 1 is accepted
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
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
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.
Dess
Telerik
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
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.
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
Hello, is it possible to change the resource color (in timeline view) avoiding the vertical gradient that's currently applied by default?
I would like to paint the resource background with the selected color without further styles.
Thank you,
Giovanni.
Hello, Giovanni,
Each Resource offers a Color property which controls what to be the color for it:
Color[] colors = new Color[]
{
Color.LightBlue, Color.LightGreen, Color.LightYellow,
Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue
};
string[] names = new string[]
{
"Alan Smith", "Anne Dodsworth",
"Boyan Mastoni", "Richard Duncan", "Maria Shnaider"
};
for (int i = 0; i new Resource();
resource.Id = new EventId(i);
resource.Name = names[i];
resource.Color = colors[i];
this.radSchedulerDemo.Resources.Add(resource);
}
Additional information about resources in available in the following help article: https://docs.telerik.com/devtools/winforms/controls/scheduler/appointments-and-dialogs/working-with-resources
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hello Dess, thank you for your reply, I'm currently using the properties you've mentioned above but the problem I'm facing is its rendering; Once I set a color, lets say Color.Orange, the control rendering event would output the requested color with a layered vertical gradient.
I would like to have the selected solid color.
Do you think it is possibile?
Giovanni.
Hello, Giovanni,
The CellFormatting event allows you to customize the style of all cells in RadScheduler. It is just necessary to specify the GradientStyle to Solid for the SchedulerResourceHeaderCellElement. Please refer to the following help article for further rinformation about the styling options in the mentioned event : https://docs.telerik.com/devtools/winforms/controls/scheduler/appearance/formatting-cells
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Thank you so much Dess!
That's exactly what I was looking for! Now it works!
Cheers,
Giovanni