Select to view content in your preferred language

Table Widget (Wrap Text)

6138
12
01-18-2022 02:43 PM
MatthewThomas1
New Contributor

Ops Dashboard now has the Table Widget which is great. Is there a way to use Arcade to allow the table to "Wrap Text". It seems like the table is designed to display a set amount of characters and not a field for longer comments. 

 

see comments that has the etc.. It does not wrap the text.see comments that has the etc.. It does not wrap the text.

12 Replies
MarcelBeckmann
Frequent Contributor

It is a little late, but in case someone else is reading this.

You have to insert the code from GFernando above the configuration of your cells.--> Bevore the return.
Exchange the long string with $datapoint.YOUR_VALUE

The wraped Text is then stored in the variable "wrapText" and you can use it in the definition of your cells.

 

var longText =$datapoint.uniqueid

// Split longText into individual words
var longTextarray = Split(longText, ' ')

// Characters per line before line break
var lineLength = 50

var wrapText = ""

var words = 0
var characters = 0

while(words < Count(longTextarray)){

// Count number of characters per line
characters += Count(longTextarray[words] + " ")

// When number of characters exceed lineLength add a line break, otherwise add a SPACE
wrapText += longTextarray[words] + When(characters >= lineLength, "<br>", " ")

// When number of characters exceed lineLength, reset characters variable back to 0
characters = When(characters >= lineLength, 0, characters)

words += 1
}

return {
  cells: {
    uniqueid: {
    displayText: wrapText,
    hoverText: $datapoint.uniqueid,
    textColor: '',
    backgroundColor: '',
    textAlign: 'left',
    iconName: '',
    iconAlign: '',
    iconColor: '',
    iconOutlineColor: ''
  },
...

0 Kudos
Deastman
Occasional Contributor

Nice one Gee!

I just used this in a link chart coming off an ArcGIS Knowledge.

 

For some reason the <br> didn't work... so subbed in textFormatting.newLine. Worked a treat.

Deastman_0-1701309833279.png

 

0 Kudos
KevinMayall
Frequent Contributor

I was just working on this a few days ago.  Great code.  Thank you!

Kevin