Forum Discussion

huffnic's avatar
huffnic
Data Storage
04-12-2024
Solved

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:

  1. When the cell value equals 'In Progress' cell background to equal #FFFFE0
  2. 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;
    		}
    	}) 
    })

     

3 Replies

  • Hello huffnic,

    Thank you for reaching out here. I see that this question hasn't had a response yet, so I am reaching out internally to try and get you and get you an answer. 

     

  • 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;
    		}
    	}) 
    })