Resource Color in grouped timeline view
Hey there,
I have appointments with two resources:
Category(only one per appointment) and Owner(multiple per appointment)
The Category resource defines a Color and the scheduler is configured to use this as Color for the appointments.
In the normal view this works fine, even in the timelineview if no grouping is active.
but if I activate grouping by the owner in the timeline view, then all shown events became the default color and the defines color by the category resource is ignored.
<SfSchedule TValue="SAppointment" Timezone="Europe/Berlin" EnableAutoRowHeight="true" @ref="Scheduler" Height="calc(100vh - 4.6rem)">
<ScheduleEventSettings DataSource="Appointments" ResourceColorField="Category" SpannedEventPlacement="SpannedEventPlacement.TimeSlot"></ScheduleEventSettings>
<ScheduleEvents TValue="SAppointment" Navigating="OnNavigating" Created="InitialLoad" Resized="Resized"></ScheduleEvents>
<ScheduleResources>
<ScheduleResource Name="Category" TItem="SCategory" TValue="int" DataSource="@Categories" Field="CategoryID" Title="Kategorie" TextField="Name" IdField="Id" ColorField="BGColor"></ScheduleResource>
<ScheduleResource Name="Owner" TItem="SOwner" TValue="int[]" DataSource="@Owners" Field="OwnerIds" Title="Beteiligte" TextField="Name" IdField="Id" AllowMultiple="true"></ScheduleResource>
</ScheduleResources>
<ScheduleGroup AllowGroupEdit="true" Resources="@GroupingResources"></ScheduleGroup>
<ScheduleViews>
<ScheduleView Option="View.Day"></ScheduleView>
<ScheduleView Option="View.Week"></ScheduleView>
<ScheduleView Option="View.Month"></ScheduleView>
<ScheduleView Option="View.TimelineDay"></ScheduleView>
<ScheduleView Option="View.TimelineWeek"></ScheduleView>
<ScheduleView Option="View.TimelineMonth"></ScheduleView>
</ScheduleViews>
</SfSchedule>
Hi Alexander Kuhlmann,
<ScheduleEventSettings ResourceColorField="Category" ... /> |
public string[] GroupingResources { get; set; } = { "Category", "Owner" }; |
<ScheduleResource Name="Owner" TItem="SOwner" TValue="int[]" DataSource="@Owners" Field="OwnerIds" Title="Beteiligte" TextField="Name" IdField="Id" ColorField="OwnerColor" <!-- Add this --> AllowMultiple="true"> </ScheduleResource> |
Regards,
Vijayakumar R
Hi Vijayakumar R,
thank you for your answer.
If I add the category to the GroupingResources, this will add an extra row for each category, this would blow up my view very much and is not what I want. I need to have a row for each owner and inside this row all appointments for this owner, but each appointment needs to be colored corresponding to its individual category.
Is there any way to achieve this? If this is not possible with features of the component maybe I can set the color dynamically on my own?
Beat,
Alex
Hi Alexander Kuhlmann,
- Maintain single-level grouping by Owner only
- Apply Category-based colors to individual appointments programmatically
- Avoid the extra rows that hierarchical grouping would create
- Access the appointment data (including Category/Room information)
- Look up the corresponding color from your resource data
- Apply the color dynamically using the args.Attributes collection
public void OnEventRendered(EventRenderedArgs<AppointmentData> args) { if (args?.Data == null) return; // Safety check // If RoomId is 0 (when creating appointments via quick popup), // automatically assign it from Owner's GroupId if (args.Data.RoomId == 0 && args.Data.OwnerId > 0) { var owner = OwnersData.FirstOrDefault(o => o.Id == args.Data.OwnerId); if (owner != null) { args.Data.RoomId = owner.OwnerGroupId; } } // Get the Room/Category color int categoryId = args.Data.RoomId; var room = RoomData.FirstOrDefault(c => c.Id == categoryId); if (room != null) { // Initialize Attributes dictionary if null args.Attributes ??= new Dictionary<string, object>(); // Apply the background color args.Attributes["style"] = $"background-color: {room.RoomColor};"; } } |
Regards,
Vijayakumar R
- 3 Replies
- 2 Participants
- Marked answer
-
AK Alexander Kuhlmann
- Jun 10, 2026 02:42 PM UTC
- Jun 17, 2026 12:45 PM UTC