Skip to content

How to change the cell color depending on the range of numerical value ​​in the Screen Index

Answer

Use "Server Script" and "Style".


Overview

In "Server Script", assign "Cell CSS" according to the range of "Numerical Value Column" specified on "Screen Index" and change the background color of the cell.

Screen index where cell background colors differ by the range of the numerical value

Operation Procedure

  1. Create a "Table".
  2. Enable "NumC (NumC)" in "List Screen Column Settings".
  3. "Create new" the following "Server Script". For "Condition", select "Before Row Display".
  4. "Create new" the following "Style". For "Destination", select "Index".

Script

JavaScript (Server Script)
// If the value of number C is less than 10,000, the background will be changed to red, if it is between 20,000 and 30,000, the background will be changed to yellow, and if it is 30,000 or more, the background will be changed to blue. The background color will be specified using a style that has been set in advance.
const total = model.NumC;
if (total < 10000) {
    columns.NumC.ExtendedCellCss = 'cell-blue';
} else if (total >= 10000 && total < 30000) {
    columns.NumC.ExtendedCellCss = 'cell-yellow';
} else if (total >= 30000) {
    columns.NumC.ExtendedCellCss = 'cell-red';
}

Style

The method for specifying elements differs between versions prior to 1.4.20.0 and later versions.

after ver1.4.20.0

CSS (Style)
/* Total is less than 10,000 JPY */
.grid td.cell-blue {
    background-color: blue;
    color: white;
}
/* Total is 10,000 JPY or more, but less than 30,000 JPY */
.grid td.cell-yellow {
    background-color: yellow;
    color: black;
}
/* Total is over 30,000 JPY */
.grid td.cell-red {
    background-color: red;
    color: black;
}

before ver1.4.19.2

CSS (Style)
/* Total is less than 10,000 JPY */
.cell-blue {
    background-color: blue;
    color: white;
}
/* Total is 10,000 JPY or more, but less than 30,000 JPY */
.cell-yellow {
    background-color: yellow;
    color: black;
}
/* Total is over 30,000 JPY */
.cell-red {
    background-color: red;
    color: black;
}