How is your experience with the OutSystems Community?
17
Views
4
Comments
How to Group an OutSystems Data Grid Column Based on Another Column's Value?

Hi ,
Is it possible to merge cells in country threat column based on the reference of country column? 

2026-05-21 07-11-43
KATHIRESAN MARKANDAN

Hi @Rahul 

I went through it, but it is not related to this scenario.

2026-03-03 06-24-34
Grijesh Suman

Hi @KATHIRESAN MARKANDAN

For achieving this scenario use the Data Grid's built-in row grouping feature. The grid supports a Group Panel where users can drag a column and group rows by that column.

Steps:

1 Select your Data Grid.

2 Set HasGroupPanel = True.

3 Publish the application.

Run the screen and drag the source column (for example, Country) into the grouping area.

The grid will automatically group rows according to that column's values.


2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @KATHIRESAN MARKANDAN ,

You can achieve this with a custom Wijmo MergeManager. Wijmo calls this restricted merging.

The standard MergeColumnCells action merges cells based only on their own value.

You can use the following JS in the OnInitialize event of the grid, you will need the GridWidgetId and column IDs of your Country & Country Threat columns. In order to get those IDs you can name the columns and then use the IDs from the Widget folder.

  1. const grid = OutSystems.GridAPI.GridManager
  2. .GetGridById($parameters.GridWidgetId).provider;
  3. const countryColumn = OutSystems.GridAPI.ColumnManager .GetColumnById($parameters.CountryColumnWidgetId).provider;

  4. const threatColumn = OutSystems.GridAPI.ColumnManager
  5.     .GetColumnById($parameters.CountryThreatColumnWidgetId).provider;

  6. class CountryMergeManager extends wijmo.grid.MergeManager {
  7.     getMergedRange(panel, row, column, clip = true) {
  8.         const isDataCell =
  9.             panel.cellType === wijmo.grid.CellType.Cell;

  10.         const isManagedColumn =
  11.             column === countryColumn.index ||
  12.             column === threatColumn.index;

  13.         if (!isDataCell || !isManagedColumn) {
  14.             return super.getMergedRange(panel, row, column, clip);
  15.         }

  16.         const range = new wijmo.grid.CellRange(row, column);
  17.         const countryValue =
  18.             panel.getCellData(row, countryColumn.index, false);
  19.         const cellValue =
  20.             panel.getCellData(row, column, false);

  21.         while (
  22.             range.row > 0 &&
  23.             panel.getCellData(
  24.                 range.row - 1,
  25.                 countryColumn.index,
  26.                 false
  27.             ) === countryValue &&
  28.             panel.getCellData(
  29.                 range.row - 1,
  30.                 column,
  31.                 false
  32.             ) === cellValue
  33.         ) {
  34.             range.row--;
  35.         }

  36.         while (
  37.             range.row2 < panel.rows.length - 1 &&
  38.             panel.getCellData(
  39.                 range.row2 + 1,
  40.                 countryColumn.index,
  41.                 false
  42.             ) === countryValue &&
  43.             panel.getCellData(
  44.                 range.row2 + 1,
  45.                 column,
  46.                 false
  47.             ) === cellValue
  48.         ) {
  49.             range.row2++;
  50.         }

  51.         return range.isSingleCell ? null : range;
  52.     }
  53. }

  54. grid.allowMerging = wijmo.grid.AllowMerging.Cells;
  55. countryColumn.allowMerging = true;
  56. threatColumn.allowMerging = true;
  57. grid.mergeManager = new CountryMergeManager();

I attached a sample OML with the implementation.

Result:

DataGridRestrictedGrouping.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.