cancel
Showing results for 
Search instead for 
Did you mean: 

Linux pivot2 - how to replace null with '-'

cglowe
8 - Cloud Apps
8 - Cloud Apps

In Windows, with pivot1, we were using the following script to replace null values with a dash (-).  We've moved to Linux and are aware the script will not work.  What script should we use to accomplish the same replacement?

Old script:

widget.on('ready', function(){
$('td[class*=p-value] div').map(function(i, cell) {
if(cell.innerHTML == " " ) cell.innerHTML="-";
})
})

1 ACCEPTED SOLUTION

harikm007
13 - Data Warehouse
13 - Data Warehouse

@cglowe ,

Please check if this script works for you : 

widget.on('ready', function(){
	$('div[class*=table-grid__content__inner]').map(function(i, cell) {
		if(cell.innerHTML == " " || cell.innerHTML == "") cell.innerHTML="-"; //change the condition based on requirement
	})
})

-Hari

 

View solution in original post

6 REPLIES 6

harikm007
13 - Data Warehouse
13 - Data Warehouse

@cglowe ,

Please check if this script works for you : 

widget.on('ready', function(){
	$('div[class*=table-grid__content__inner]').map(function(i, cell) {
		if(cell.innerHTML == " " || cell.innerHTML == "") cell.innerHTML="-"; //change the condition based on requirement
	})
})

-Hari

 

harikm007
13 - Data Warehouse
13 - Data Warehouse

Another solution is to use Pivot2 API : 

widget.transformPivot(
    {
        type: ['value']
    },
    function setCellBackground(metadata, cell) {
        if(cell.content.trim() == '')
			cell.content = '-'
    }
)

-Hari

BIQ
8 - Cloud Apps
8 - Cloud Apps

Is there a script that will replace instances of NaN:NaN:NaN in Blox widget with a '-'?

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @BIQ ,

Hope below script works for you. Update the value/text for the variables as per the comment in script

widget.on('processresult', function(se, ev){
	
	let panelName = 'Region' //update your panel name here
	let textToRepalce = '$10.18M' //update value of text to be replaced
	let replaceWith = '-' //new value/text to be displayed
	
	$.each(ev.result, function(resultIndex, resultValue){
		$.each(resultValue, function(index, value){
			if(value.Panel == panelName && value.Text == textToRepalce){
				value.Text = replaceWith
			}
		})
		
	})

})

-Hari

BIQ
8 - Cloud Apps
8 - Cloud Apps

Works great. Thank you @harikm007 

@harikm007  thank you for the script.

@cglowe I would like to add that we at Paldi Solutions designed and developed the "expandable pivot" plugin after many years of working with clients who had diverse needs for the pivot table just like the one you raised.

Furthermore, we have developed the "widget script manager"  plugin that allows you to control all code snippets that are applied to widgets; with this plugin, you can manage the code from a single central place.

 

Feel free to reach out for free trials, we're always happy to help (: 
Paldi Solutions - Number #1 Sisense Plugins Developer