Forum Discussion

cglowe's avatar
cglowe
Cloud Apps
02-07-2022
Solved

Linux pivot2 - how to replace null with '-'

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="-";
})
})

  • 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

     

6 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    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's avatar
      harikm007
      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's avatar
      BIQ
      Cloud Apps

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

      • harikm007's avatar
        harikm007
        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

    • Benji_PaldiTeam's avatar
      Benji_PaldiTeam
      Data Pipeline

      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