Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Page layout facilities > Styles > Grids > Body cell background color
 
Body cell background color
With grids, the body cell background color is the color of the cells formed by the intersection of a row response with a column response; it does not apply to the row and column headings nor to the area of the page covered by the grid table as a whole. Row and column headings are label texts and are treated the same as any other categorical response texts. For more information, see Question, response, and information text.
You can apply the same color to all body cells or to all the cells in a particular row or column, and there are commands that make it easy to switch between two colors for alternate rows or columns. You can also specify colors for individual cells if that is what you want:
Grid with different background color in every cell
This graphic is described in the surrounding text.
To set the background color for a body cell within a grid, place the following statement in the routing section of the script:
<grid_name>[<grid_category>].<question_name>.Categories[<category>].Style.Cell.BgColor = "<color>"
where:
<grid_name> is the name of the grid.
<grid_category> is the name of a category for which <question_name> is repeated (that is, one of the categories named at the start of the grid definition). If the setting applies to all categories, use [..].
<question_name> is the name of the repeated question.
<category> is the name of a response in <question_name>’s response list. Use [..] to refer to all responses.
<color> is the name or RGB code of the color you want to use. For a complete list of the color names that you can use and their equivalent RGB (hexadecimal) values, refer to your HTML documentation.
The first row of the illustration was created by the following statements:
With TeaLoop[{Assam}].Countries
  .Categories[{China}].Style.Cell.BgColor = "#404000"
  .Categories[{India}].Style.Cell.BgColor = "#808000"
  .Categories[{Japan}].Style.Cell.BgColor = "#C0C000"
  .Categories[{Kenya}].Style.Cell.BgColor = "#FFFF00"
  .Categories[{SouthAfrica}].Style.Cell.BgColor = "#FFFF40"
  .Categories[{SriLanka}].Style.Cell.BgColor = "#FFFF80"
End With
To set the background color for the cells in the row text column, type:
<grid_name>.Categories[..].Label.Style.Cell.BgColor = "<color>"
To set the background color for the cells in the column heading row, type:
<grid_name>[..].<question_name>.Categories[..].Label.Style.Cell.BgColor = "<color>"
For example:
TeaLoop.Categories[..].Label.Style.Cell.BgColor = "#FFC0C0" 'pink
TeaLoop[..].Countries.Categories[..].Label.Style.Cell.BgColor = "#C0FFC0" 'green
This graphic is described in the surrounding text.
Both statements include the Cell object. This indicates that the color specification refers to the whole grid cell rather than just to the background color of the text.
It is the categories of the grid (that is, the categories for which the question is repeated) that determine how the row labels in a standard grid are presented. It is the responses to the repeated question that determine how the column labels are presented.
See also
Grids