alternate colors - timeLineWeek & workWeek
Hi Isabelle Fuchs,
You can achieve your requirement by utilizing the schedule renderCell
event and the resourceHeaderTemplate, which should meet your needs.
The attached example demonstrate the
solution. Please give it a try, and feel free to reach out if you need further
assistance.
Sample: https://stackblitz.com/edit/vue-schedule-resourcetemplate-x7drvw?file=src%2FApp.vue
[app.component.ts]
|
id="Schedule" height="650px" :cssClass="cssClass" :selectedDate="selectedDate" :eventSettings="eventSettings" :group="group" :currentView="currentView" :renderCell="onRenderCell" :resourceHeaderTemplate="'resourceHeaderTemplate'" >
<template v-slot:resourceHeaderTemplate="{ data }"> <div class="template-wrap" :class="getBackgroundClass(data)"> <div class="resource-image"> <img class="resource-image" :src="getImage(data)" :alt="getImage(data)" /> </div> <div class="resource-details"> <div class="resource-name">{{ getEmployeeName(data) }}</div> <div class="resource-designation"> {{ getEmployeeDesignation(data) }} </div> <div class="resource-designation"> {{ getEmployeeDesignation(data) }} </div> <div class="resource-designation"> {{ getEmployeeDesignation(data) }} </div> </div> </div> </template>
debugger; let resourceName = this.getEmployeeName(data); if (resourceName === 'Margaret') { return 'margaret-resource'; } else if (resourceName === 'Robert') { return 'robert-resource'; } else { return 'Laura-resource'; } }, onRenderCell: function (args) { if (args.elementType === 'resourceHeader') { if ( args.element.firstElementChild.classList.contains('margaret-resource') ) { args.element.style.backgroundColor = 'lightblue'; } else if ( args.element.firstElementChild.classList.contains('robert-resource') ) { args.element.style.backgroundColor = 'yellow'; } else if ( args.element.firstElementChild.classList.contains('Laura-resource') ) { args.element.style.backgroundColor = 'green'; } } if ( args.elementType === 'dateHeader' || args.elementType == 'workCells' ) { if (args.date.getDate() % 2 !== 0) { args.element.style.backgroundColor = 'grey'; } } if (args.element.classList.contains('e-time-slots')) { args.element.style.backgroundColor = 'grey'; }
|
Regards,
Ashok
the rows of the dates also should be in the same color like the resources!
Hi Isabelle Fuchs,
You can fulfill your requirement
by utilizing the renderCell
event. If the event is used, you can apply background styles based on the data-group
index. The attached example demonstrates the solution. Feel free to give it
a try, and don't hesitate to reach out if you need further assistance.
Sample: https://stackblitz.com/edit/vue-schedule-resourcetemplate-6uuzcr?file=src%2FApp.vue
|
if(args.elementType === "workCells") { if(args.element.getAttribute('data-group-index') === '0') { args.element.style.backgroundColor = 'lightblue';
} else if (args.element.getAttribute('data-group-index') === '1') { args.element.style.backgroundColor = 'yellow'; } else { args.element.style.backgroundColor = 'green'; } } },
|
Screenshot:
Regards,
Ashok
one more question - I need for the parent resource a different color
so AUhof = dark green
Buhr Sabine - should be light green
but the first group get the color but the second not.. I need to identify the parent group... but how?
Hi Isabelle Fuchs,
We have created a separate forum for this query. Please follow the below ticket for further details.
Regards,
Ashok
- 5 Replies
- 3 Participants
-
IF Isabelle Fuchs
- Feb 19, 2024 10:57 AM UTC
- Feb 23, 2024 01:37 PM UTC