I found this wonderful code (Color-Coding in DataPages - Caspio Online Help) that works beautifully, however, it only looks at one field. I have two different fields in two differnt positions that I need the colors to change on. So here is the code I have:
The "Leave" and "Vacation" field is in the TypeOfLeave field, order number 4 of the appointment type in the Calendar Wizard. I need to reference 3 and 4 in the code. Any ideas on how to do this?
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
khale
Hello,
I found this wonderful code (Color-Coding in DataPages - Caspio Online Help) that works beautifully, however, it only looks at one field. I have two different fields in two differnt positions that I need the colors to change on. So here is the code I have:
<script>
const colorToEvent = {
'Glenn Mercer': '#6AA6C8',
'Archie': '#B5F5F8',
'Angela': '#F6B3A2',
'Lorecel': '#F7FEB3',
'Leave': '#4B2EFA',
'Vacation': '#FD3A2B',
'Frances': '#7EC2BC',
'Tonie': '#60C277'
}
const setRelevantHeight = () => {
const elems = document.querySelectorAll('.cbResultSetPanelDataContainer');
let maxHeight = 0;
elems.forEach(elem => {
const newHeight = elem.offsetHeight;
maxHeight = newHeight > maxHeight ? newHeight : maxHeight;
})
document.querySelectorAll('dl dd:nth-of-type(3)').forEach(name => {
let eventType = name.innerHTML;
name.parentElement.parentElement.style = `background-color: ${colorToEvent[eventType]}; margin-bottom: 10px; border-radius: 10px; height: ${maxHeight + 'px'}`;
})
}
document.addEventListener('DataPageReady', setRelevantHeight)
window.addEventListener('resize', setRelevantHeight)
</script>
[@app:MainHomePage]
The "Leave" and "Vacation" field is in the TypeOfLeave field, order number 4 of the appointment type in the Calendar Wizard. I need to reference 3 and 4 in the code. Any ideas on how to do this?
Thanks
Link to comment
Share on other sites
18 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.