Select to view content in your preferred language

Row striping in Table widget with Advanced Formatting

1147
3
Jump to solution
09-29-2022 03:24 PM
RhettZufelt
MVP Notable Contributor

I am trying to make some Pivot Tables in Dashboard with Table widget.

there is a default options to toggle on row striping and it alternates the color of the rows:

RhettZufelt_0-1664490094654.png

 

However, if you choose Advanced Formatting for the values, the arcade overrides all the row striping, and I can't find any example/method to turn that back on with arcade. 

RhettZufelt_1-1664490231311.png

 

Is this possible?  Any samples out there similar to this?

Thanks,

R_

 

 

0 Kudos
1 Solution

Accepted Solutions
Kepa
by Esri Contributor
Esri Contributor

Hi there,

I don't know if you finally figured this out but in case someone needs it you can use a simple logic before the return statement to check $rowindex value using module operator:

 

var color = ''
if ($rowindex %2 == 0) {
    color = '#3ff6f6'
}
else {
    color = '#ffffff'
}

 

And then you just set color variable to background property. You can see the result in the attachment png.

Hope this helps anyone out there.

Regards.

View solution in original post

0 Kudos
3 Replies
Kepa
by Esri Contributor
Esri Contributor

Hi there,

I don't know if you finally figured this out but in case someone needs it you can use a simple logic before the return statement to check $rowindex value using module operator:

 

var color = ''
if ($rowindex %2 == 0) {
    color = '#3ff6f6'
}
else {
    color = '#ffffff'
}

 

And then you just set color variable to background property. You can see the result in the attachment png.

Hope this helps anyone out there.

Regards.

0 Kudos
JerrySneary
New Contributor III

Hi @Kepa ,

This is my code for row striping and it works but now I noticed that I can't do individual background cell color. Is there a way within the for loop to do individual cell color and row color?

var bgColor = When($rowindex %2 == 0, '#ffffff', '#F8F8F8');                                     

for (var cell in row.cells) {
    row.cells[cell].backgroundColor = bgColor;
}

't 

0 Kudos
RhettZufelt
MVP Notable Contributor

Thank you @Kepa , but yes, I did figure this out.

However, came up with the same solution, so will mark your post as the answer.

R_

 

0 Kudos