Select to view content in your preferred language

Dashboard Table Advanced Formatting, Conditionally show URL

190
2
Jump to solution
12-04-2024 12:42 PM
rbd
by
Occasional Contributor

Winter greetings,

I've got a Dashboard Table with 3 columns:

  • column 1: text of cell
  • columns 2 and 3: I've successfully used advanced formatting to display a link to the cell's stored URL text string.

However... there are a couple of cells in columns 2 and 3 that are null/empty and will remain that way. I'd like for those cells not to display a clickable link that goes nowhere, and instead to simply show up as empty. I can't figure out where in the code to put the if(IsEmpty()) variables. Column 1 I need to remain as-is. Below is my working code:

 

return {
  cells: {
    TreatyImp: {
      displayText : $datapoint.TreatyImp,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Topo: {
      displayText : `<a href="${$datapoint["Topo"]}" target="blank">Download Topo Map</a>`,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Aerial: {
      displayText : `<a href="${$datapoint["Aerial"]}" target="blank">Download Aerial Map</a>`,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },	
  }
}

 

Any pointers in the right direction would be appreciated. 

-r

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Give this a try

var topoText = When(IsEmpty($datapoint["Topo"]), '', `<a href="${$datapoint["Topo"]}" target="blank">Download Topo Map</a>`)
var aerialText = When(IsEmpty($datapoint["Aerial"]), '', `<a href="${$datapoint["Aerial"]}" target="blank">Download Aerial Map</a>`)

return {
  cells: {
    TreatyImp: {
      displayText : $datapoint.TreatyImp,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Topo: {
      displayText : topoText,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Aerial: {
      displayText : aerialText,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },	
  }
}

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

Give this a try

var topoText = When(IsEmpty($datapoint["Topo"]), '', `<a href="${$datapoint["Topo"]}" target="blank">Download Topo Map</a>`)
var aerialText = When(IsEmpty($datapoint["Aerial"]), '', `<a href="${$datapoint["Aerial"]}" target="blank">Download Aerial Map</a>`)

return {
  cells: {
    TreatyImp: {
      displayText : $datapoint.TreatyImp,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Topo: {
      displayText : topoText,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
		
    Aerial: {
      displayText : aerialText,
      textColor: '',
      backgroundColor: '',
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },	
  }
}
rbd
by
Occasional Contributor

@KenBuja you're amazing! Thanks for the fix. BTW, I've been chasing rabbitholes on these boards and have learned a lot from your posts and responses to others!

0 Kudos