Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Dynamic alter colour cell with JavaScript

Avatar

Avatar
Level 1
diogofbp
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
diogofbp
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
diogofbp
Level 1

22-06-2016

Hello Guys,

I'm facing the current problem:

I want change a colour cell depends on the value of the cell variable. I'm using the following JavaScript code on the initialize event of this cell

data.First.MainTable.Table1.Row1.Cell6::initialize - (JavaScript, client)

var numrows = xfa.resolveNodes("data.First.MainTable.Table1.Row1[*]").length;

for (var i = 0; i < numrows; i++)

{

    var LV_DATA = xfa.resolveNode("data.First.MainTable.Table1.Row1[" + i + "].Cell6");

  

    switch(LV_DATA){

       case LV_DATA <= "2":

            this.border.fill.color.value = "0, 153, 0";

            break;

       case LV_DATA >= "3" && LV_DATA <= "6":

            this.border.fill.color.value = "255, 255, 0";

            break;

       case LV_DATA> "6":

            this.border.fill.color.value = "255, 0, 0";

            break;

       default:

            this.border.fill.color.value = "255, 255, 255";

    }

}

Print1.PNG

My output values is:

Print2.PNG

With this output on column RISK Level I should get the first two cells red and the last one yellow.

Can you help me?

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 2
Karwan_Mawlood
Level 2

Likes

7 likes

Total Posts

43 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
Karwan_Mawlood
Level 2

Likes

7 likes

Total Posts

43 posts

Correct Reply

3 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
Karwan_Mawlood
Level 2

23-06-2016

Hi Diogofbp,

welcome to Adobe.

Please use below code there is some errors in your code, and use the layoutready.

data.First.MainTable.Table1.Row1.Cell6::layoutReady - (JavaScript, client)

var numrows = data.First.MainTable.Table1.Row1.instanceManager.count;

for (var i = 0; i < numrows; i++)

{

    var LV_DATA = xfa.resolveNode("data.First.MainTable.Table1.Row1["  +  i  +  "]").Cell6.rawValue;

    switch(LV_DATA){

      case LV_DATA <= "2":

            this.border.fill.color.value = "0, 153, 0";

            break;

      case LV_DATA >= "3" && LV_DATA <= "6":

            this.border.fill.color.value = "255, 255, 0";

            break;

      case LV_DATA> "6":

            this.border.fill.color.value = "255, 0, 0";

            break;

      default:

            this.border.fill.color.value = "255, 255, 255";

    }

}