huffnic
04-12-2024Data Storage
Seeking help with a widget script for cell.value
Hello,
I am currently using the following widget script for a pivot using rows (no values or columns) on windows OS:
widget.transformPivot({},
function(metadata, cell) {
if (cell.value == 'Resolved') {
cell.style = {
backgroundColor: '#90EE90'
}
} else if (cell.value == 'Open') {
cell.style = {
backgroundColor: '#FF7F7F'
}
};
}
);
I need two additional conditions. They are:
- When the cell value equals 'In Progress' cell background to equal #FFFFE0
- When the cell value equals 'Not Applicable' (a default value when no data has been entered into the relevant field) the cell will be blank or the text will be white to blend the words into the background essentially hiding the words 'Not Applicable'.
Any assistance to decrease the visual clutter for end users would be greatly appreciated.
Hi huffnic,
The script you are using utilizes our Pivot 2.0 API which is for Linux only. You can try the below script for Windows. Let me know if this is helpful.
-Tri
widget.on('ready', function(){ $('td[class*=p-value] div').map(function(i, cell) { switch (cell.innerHTML) { case "Resolved": cell.style.backgroundColor='#90EE90'; break; case "Open": cell.style.backgroundColor='#FF7F7F'; break; case "In Progress": cell.style.backgroundColor='#FFFFE0'; break; case "Not Applicable": cell.innerHTML=''; break; } }) })