> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Collapse Column Groups

> Group related columns under a shared header and let users collapse the group to a single representative column when they need a more focused view of the grid.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

<Info title="Verify in application">
  This guide describes column grouping and the `collapseTo` behavior using the verified column properties `headerGroup` and `collapseTo`. The exact UI affordance for collapsing a group (header click, group menu, or keyboard shortcut) may vary by Nextedy RISKSHEET version — confirm the click target in your environment.
</Info>

## When to use column groups

Column groups are useful when a Risksheet configuration contains many columns and the analyst wants to switch between a detailed and a summary view without creating separate saved views. Typical examples:

* Failure Mode and Effects Analysis (FMEA) sheets that group the **Initial Assessment**, **Mitigation**, and **Final Assessment** columns
* Hazard Analysis and Risk Assessment (HARA) sheets that group ASIL components (severity, exposure, controllability)
* Threat Analysis and Risk Assessment (TARA) sheets that group impact and feasibility ratings

When a group is collapsed, every column inside the group is hidden EXCEPT the columns flagged with `collapseTo: true`, which remain visible as the group's representative summary.

## How grouping and collapsing fit together

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/yWl5nA2D0IzEnZC1/risksheet/diagrams/guides/customization/collapse-column-groups/diagram-1.svg?fit=max&auto=format&n=yWl5nA2D0IzEnZC1&q=85&s=325c091deaa9af0ec159981e66d7bf06" alt="diagram" style={{ maxWidth: "640px", width: "100%" }} width="640" height="230" data-path="risksheet/diagrams/guides/customization/collapse-column-groups/diagram-1.svg" />
</Frame>

<Steps>
  <Step title="Decide which columns belong to a group">
    Pick columns that always make sense together for the analyst. A column group works best when:

    * The columns share a domain meaning (for example, all parameters that feed the same Risk Priority Number).
    * The analyst frequently toggles between a "detail" mindset (entering severity, occurrence, detection) and a "summary" mindset (reading RPN).
    * At least one column in the group is a calculated or rolled-up value that can stand in for the rest when collapsed.
  </Step>

  <Step title="Add `headerGroup` to each member column">
    Open the sheet configuration through **Menu > Configuration > Edit Risksheet Configuration**. In the `columns` array, set the same `headerGroup` string on every column that belongs to the group:

    ```yaml theme={null}
    columns:
      - id: severity
        header: S
        bindings: severity
        type: rating:severityEnum
        headerGroup: Initial Assessment
        level: 2
      - id: occurrence
        header: O
        bindings: occurrence
        type: rating:occurrenceEnum
        headerGroup: Initial Assessment
        level: 2
      - id: detection
        header: D
        bindings: detection
        type: rating:detectionEnum
        headerGroup: Initial Assessment
        level: 2
      - id: rpn
        header: RPN
        formula: computeRpn
        headerGroup: Initial Assessment
        collapseTo: true
        level: 2
    ```

    The `headerGroup` value becomes the merged header bar displayed above the member columns. Any number of groups can coexist in the same sheet — just use distinct `headerGroup` strings (for example, `Initial Assessment`, `Mitigation`, `Final Assessment`).

    <Tip title="Group the Initial/Mitigation/Final triplet">
      For an FMEA workflow it is common to define three parallel groups (`Initial Assessment`, `Mitigation`, `Final Assessment`) with the same internal structure (severity, occurrence, detection, RPN). Analysts then collapse the groups they are not actively editing, keeping the corresponding RPN columns visible for comparison.
    </Tip>
  </Step>

  <Step title="Pin a summary column with `collapseTo`">
    Add `collapseTo: true` to the column that should remain visible when the group is collapsed. Typical choices are:

    * The calculated RPN (or any composite score)
    * A classification column such as ASIL or risk class
    * A status column that summarises the group

    | Column property | Type    | Meaning                                                                      |
    | --------------- | ------- | ---------------------------------------------------------------------------- |
    | `headerGroup`   | string  | Name of the column group. Same value on every member column.                 |
    | `collapseTo`    | boolean | When `true`, the column stays visible while the rest of the group is hidden. |

    <Warning title="collapseTo is a boolean, not a string">
      Earlier drafts of community examples sometimes show `collapseTo: "rpn"` or another column id. That form is not valid in Risksheet. The property is a boolean — set `collapseTo: true` on the column you want to keep visible. To change which column persists when the group is collapsed, move the `true` flag to a different column.
    </Warning>
  </Step>

  <Step title="Save and reload the document">
    Save the sheet configuration. Reload the Polarion LiveDoc that hosts the risksheet so the new grouping takes effect. The grid renders a second header row showing the group name, with the member columns aligned underneath.

    <Tip title="Check the result in the configuration editor preview">
      The configuration editor in v25.5.0+ supports a YAML view with live syntax checking. Use it to confirm that every member column has the same `headerGroup` value before saving — a typo on one column will split the group into two.
    </Tip>
  </Step>

  <Step title="Collapse and expand the group">
    In the rendered grid, click the group header to collapse all member columns down to those flagged with `collapseTo: true`. Click again to expand the group back to its full set of columns. The collapsed state is per-user and per-session — it does not modify the sheet configuration.

    If you want a specific collapsed-by-default layout for every analyst, combine column groups with a saved view: define a view that excludes the detailed columns, and another that includes them all. See [Create Saved Views](/risksheet/guides/customization/saved-views) for the `columnIds`, `@all`, and `-columnId` syntax.
  </Step>
</Steps>

## Pitfalls and tips

<Warning title="Levels must agree across the group">
  Every column in a group should share the same `level` value. If one member sits on a different visual level, the group header will not align correctly with the columns below it. See [Display Multi-Level Hierarchies](/risksheet/guides/columns/multi-level-hierarchy) for how level values are used for cell merging.
</Warning>

<Warning title="Tasks (downstream) columns do not take a level">
  Columns bound to `task.*` fields are rendered with their own merging logic and do not participate in the same level hierarchy as risk-item columns. If you create a group that mixes risk-item and task columns, expand and collapse may look inconsistent. Prefer grouping columns that bind to the same data type.
</Warning>

<Tip title="Use groups together with views">
  Column groups are a per-user runtime affordance — they let an analyst hide detail temporarily. Saved views, by contrast, define persistent column subsets shared across users. Use the two together: one named saved view per workflow stage, and groups inside each view for in-stage focus.
</Tip>

<Tip title="Keep the summary column meaningful">
  The column flagged with `collapseTo: true` becomes the only signal the analyst sees when the group is collapsed. Pick a column that is calculated from the others (for example, a Risk Priority Number formula) so that the collapsed view still conveys the group's outcome. See [Configure Calculated Columns](/risksheet/guides/columns/calculated-columns) for the formula syntax.
</Tip>

## Verification

You should now see:

* A merged header bar labelled with your `headerGroup` value above the member columns.
* Clicking the group header collapses all member columns except the one with `collapseTo: true`.
* Clicking the collapsed header expands the group back to the full column set.
* The collapse state persists for the current session but does not change the stored sheet configuration.

## See also

* [Create Saved Views](/risksheet/guides/customization/saved-views) — persistent named column subsets, complementary to runtime collapse.
* [Control Column Visibility](/risksheet/guides/customization/column-visibility) — broader strategies for showing and hiding columns.
* [Display Multi-Level Hierarchies](/risksheet/guides/columns/multi-level-hierarchy) — using `level` and `controlColumn` for cell merging.
* [Configure Calculated Columns](/risksheet/guides/columns/calculated-columns) — formulas suitable for summary columns kept visible on collapse.
* [Use the Configuration Editor](/risksheet/guides/configuration/using-config-editor) — YAML editing workflow for the sheet configuration.

<LastReviewed date="2026-06-22" />
