@one-grid-core/angular 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import { v4 } from 'uuid';
2
2
  import * as i0 from '@angular/core';
3
3
  import { Injectable, inject, NgZone, Pipe, Input, Component, EventEmitter, HostListener, ViewChildren, Output, ViewChild, ChangeDetectionStrategy, Directive, NgModule } from '@angular/core';
4
4
  import { BehaviorSubject, Subject, Subscription } from 'rxjs';
5
- import _ from 'lodash';
5
+ import lodash from 'lodash';
6
6
  import { filter, map, debounceTime, take } from 'rxjs/operators';
7
7
  import { NgClass, NgStyle, NgTemplateOutlet, DecimalPipe } from '@angular/common';
8
8
  import * as i2 from 'lucide-angular';
@@ -148,10 +148,20 @@ const ONE_GROUP_VALUE_FIELD = '__oneGroupValue';
148
148
  const ONE_GROUP_CHILDREN_FIELD = '__oneGroupChildren';
149
149
  /** What a group of rows with no value in the grouped field is labelled. */
150
150
  const ONE_GROUP_BLANK_LABEL = '(Blank)';
151
- /** The `rowGroup` fields of a column set, in definition order. */
151
+ /**
152
+ * The `rowGroup` fields of a column set, in definition order.
153
+ *
154
+ * Grouping keys on a row's own field, so a column that asks to group without
155
+ * one has nothing to group by — it is dropped, but not silently: that is a
156
+ * definition that reads as if it works.
157
+ */
152
158
  function rowGroupFields(columns) {
153
- return (columns ?? [])
154
- .filter(column => column.rowGroup && column.field)
159
+ const grouping = (columns ?? []).filter(column => column.rowGroup);
160
+ for (const column of grouping.filter(column => !column.field)) {
161
+ console.warn(`[one-grid] the column "${column.headerName ?? column.id ?? '(unnamed)'}" declares rowGroup but has no field — grouping reads the row's own value, so a valueGetter is not enough. The column was left ungrouped.`);
162
+ }
163
+ return grouping
164
+ .filter(column => column.field)
155
165
  .map(column => column.field);
156
166
  }
157
167
  /** The `aggFunc` columns of a column set. */
@@ -714,6 +724,16 @@ class OgColumnService {
714
724
  this.setGroupColumnDefs(groupColumnDefs);
715
725
  this.setColumnDefs(columnDefs);
716
726
  }
727
+ /**
728
+ * Every registered column, hidden ones included, in display order.
729
+ *
730
+ * `getColumnState` answers what is on screen; this answers what the grid
731
+ * knows about — which is what anything reading a column's *configuration*
732
+ * (an `aggFunc`, say) needs, since hiding a column does not unconfigure it.
733
+ */
734
+ getAllColumnDefs() {
735
+ return this.allColumnDefs;
736
+ }
717
737
  getColumnState() {
718
738
  const columns = this.columnDefs$.getValue();
719
739
  const groups = this.groupColumnDefs$.getValue();
@@ -728,7 +748,7 @@ class OgColumnService {
728
748
  const column = {
729
749
  ...this.defaultColumnDef,
730
750
  ...col,
731
- id: col?.field ? col.field : _.uniqueId('col_'),
751
+ id: col?.field ? col.field : lodash.uniqueId('col_'),
732
752
  };
733
753
  return this.resolveHeaderPresentation(column);
734
754
  });
@@ -823,7 +843,7 @@ class OgColumnService {
823
843
  * place relative to its neighbours.
824
844
  */
825
845
  reorderColumnDefs(fromIndex, toIndex) {
826
- const columns = _.clone(this.allColumnDefs);
846
+ const columns = lodash.clone(this.allColumnDefs);
827
847
  const visible = columns.filter(column => !column.hide);
828
848
  const moved = visible[fromIndex];
829
849
  if (!moved)
@@ -1425,12 +1445,26 @@ class OneGridApi {
1425
1445
  this._quickFilterValue = null;
1426
1446
  this._activeFilters = [];
1427
1447
  this._visibleRowNodes = [];
1448
+ /**
1449
+ * The rows as the host last handed them over — before grouping folded
1450
+ * them. Grouping is a transform on the way in, so this is what a change of
1451
+ * grouping re-folds, and it is why regrouping keeps the host's row order
1452
+ * instead of inheriting the order the previous grouping happened to leave.
1453
+ */
1454
+ this._sourceRows = [];
1428
1455
  this._pinnedRowNodes = { top: [], bottom: [] };
1429
1456
  this._originalRowNodes = new Map();
1430
1457
  this._nodeCleanupMap = new Map(); // Cleanup registry (prevents memory leaks)
1431
1458
  this._destroyed = false;
1432
1459
  // Advanced Features
1433
1460
  this.treeData = false;
1461
+ /**
1462
+ * Whether the *host* declared tree data, as opposed to grouping having
1463
+ * turned tree mode on. `treeData` above answers "is this a tree right now",
1464
+ * which grouping flips; this answers "whose tree is it", which decides
1465
+ * whether grouping may touch it at all.
1466
+ */
1467
+ this._hostTreeData = false;
1434
1468
  this.treeDataChildrenField = null;
1435
1469
  this.groupDefaultExpanded = 0;
1436
1470
  this.masterDetail = false;
@@ -1472,6 +1506,7 @@ class OneGridApi {
1472
1506
  this.detailCellRendererParams = detailCellRendererParams;
1473
1507
  this.detailRendererComponent = detailRendererComponent;
1474
1508
  this.treeData = treeData;
1509
+ this._hostTreeData = treeData;
1475
1510
  this.selectionService.setSelectionMode(rowSelection);
1476
1511
  // Synthetic group rows carry their own stable id — the path of group
1477
1512
  // values — which no host getRowId knows how to derive. The wrapper reads
@@ -1555,6 +1590,9 @@ class OneGridApi {
1555
1590
  }
1556
1591
  return next;
1557
1592
  });
1593
+ // Grouped roots are synthetic, so the data is on the leaves; otherwise the
1594
+ // roots are the data. Read from the nodes rather than from `_sourceRows`
1595
+ // so a reorder the user dragged into place survives the transaction.
1558
1596
  const currentRows = grouping
1559
1597
  ? this._rowNodes.filter(node => node.leaf).map(node => node.data)
1560
1598
  : this._rowNodes.filter(node => !node.parent).map(node => node.data);
@@ -1576,6 +1614,7 @@ class OneGridApi {
1576
1614
  this.selectionService.deselectAll();
1577
1615
  this.expansionService.clear();
1578
1616
  }
1617
+ this._sourceRows = rowData ?? [];
1579
1618
  // Row grouping is a transform on the way in: the host keeps handing the
1580
1619
  // grid flat rows, and the tree pipeline below sees synthetic group rows
1581
1620
  // with children — the same shape tree data arrives in.
@@ -1627,6 +1666,14 @@ class OneGridApi {
1627
1666
  if (node) {
1628
1667
  node.data = data;
1629
1668
  node.setRowIndex(this._currentIndex);
1669
+ // Where a row sits is rebuilt, not remembered. A reused node used to
1670
+ // keep the level and parent it had when it was first built, so a row
1671
+ // that changed place in the hierarchy — a leaf moved to another
1672
+ // parent, or lifted to the root when the grouping changed — kept
1673
+ // pointing at its old parent, and the visibility walk (which climbs
1674
+ // parents) hid it behind a node that was no longer above it.
1675
+ node.level = level;
1676
+ node.parent = parent;
1630
1677
  }
1631
1678
  else {
1632
1679
  node = new OneRowNode(rowId, data, this._currentIndex);
@@ -2256,14 +2303,56 @@ class OneGridApi {
2256
2303
  return this._rowGroupFields;
2257
2304
  }
2258
2305
  /**
2259
- * Turn row grouping on. Called by `OneGridComponent` when column
2260
- * definitions declare `rowGroup`; the grid then behaves as a tree over
2261
- * synthetic group rows, and `setRowData` / `updateRowData` keep taking the
2262
- * flat rows they always took.
2306
+ * Group the rows by these fields, in nesting order — or ungroup by passing
2307
+ * an empty array.
2308
+ *
2309
+ * `OneGridComponent` calls this once for the column definitions that
2310
+ * declare `rowGroup`; hosts call it to regroup afterwards. Either way the
2311
+ * grid re-plumbs itself around the new grouping — tree mode, the auto group
2312
+ * column, the visibility of the grouped-by columns — and folds the rows it
2313
+ * already holds again, so nothing has to be rebound and no grid has to be
2314
+ * torn down and re-created to group by a different column.
2315
+ *
2316
+ * `aggregations` defaults to the `aggFunc` columns currently registered, so
2317
+ * `setRowGrouping(['country'])` keeps the totals the column definitions
2318
+ * already describe.
2263
2319
  */
2264
- setRowGrouping(groupFields, aggregations = []) {
2265
- this._rowGroupFields = groupFields ?? [];
2266
- this._aggColumns = aggregations ?? [];
2320
+ setRowGrouping(groupFields, aggregations) {
2321
+ if (this._destroyed)
2322
+ return;
2323
+ const previous = this._rowGroupFields;
2324
+ // Empty fields buy nothing and a repeated one would nest a level under
2325
+ // itself, where every child group holds the whole parent.
2326
+ const next = (groupFields ?? [])
2327
+ .filter(field => !!field)
2328
+ .filter((field, index, fields) => fields.indexOf(field) === index);
2329
+ // Grouping *is* the tree. A host that brought its own tree data, or a
2330
+ // master/detail grid, already has a hierarchy, and folding a second one
2331
+ // over it would throw the first away.
2332
+ if (next.length && (this._hostTreeData || this.masterDetail)) {
2333
+ console.warn('[one-grid] setRowGrouping does not apply to tree data or master/detail grids — they carry their own hierarchy. Nothing was changed.');
2334
+ return;
2335
+ }
2336
+ const unchanged = next.length === previous.length && next.every((field, index) => field === previous[index]);
2337
+ if (unchanged && !aggregations)
2338
+ return;
2339
+ this._rowGroupFields = next;
2340
+ this._aggColumns = aggregations ?? aggColumns(this.columnService.getAllColumnDefs());
2341
+ // The row model's half of the switch: grouped rows carry their children
2342
+ // under the grouping helper's own field, and the tree pipeline walks them
2343
+ // from there. Ungrouping puts both back — which is safe because the guard
2344
+ // above means tree mode can only have come from grouping.
2345
+ this.treeData = next.length > 0;
2346
+ this.treeDataChildrenField = next.length ? ONE_GROUP_CHILDREN_FIELD : null;
2347
+ // Everything grouping implies outside the row model — the auto group
2348
+ // column, which of the host's columns are hidden, the grid type the body
2349
+ // renders — belongs to the component that owns the template. It re-plumbs
2350
+ // on this event, synchronously, so the rebuild below already sees the
2351
+ // columns the new grouping needs.
2352
+ this.eventService.dispatchEvent('rowGroupingChanged', { groupFields: next, previousGroupFields: previous });
2353
+ // Nothing to fold before the first load: `setRowData` will do it.
2354
+ if (this._rowNodes.length)
2355
+ this.rebuildRows(this._sourceRows, false);
2267
2356
  }
2268
2357
  /**
2269
2358
  * Start recording committed cell edits for undo/redo. Called by
@@ -4016,6 +4105,7 @@ class OneGridRowActionComponent {
4016
4105
  this.detailActiveExcludeLevels = new Set(this.column.cellRendererParams?.detailActiveExcludeLevels ?? []);
4017
4106
  this.gotoDetailExcludeLevels = new Set(this.column.cellRendererParams?.gotoDetailExcludeLevels ?? []);
4018
4107
  this.addNewExcludeLevels = new Set(this.column.cellRendererParams?.addNewExcludeLevels ?? []);
4108
+ this.gotoListExcludeLevels = new Set(this.column.cellRendererParams?.gotoListExcludeLevels ?? []);
4019
4109
  }
4020
4110
  /**
4021
4111
  * Trigger Invoke Click Event
@@ -4122,11 +4212,11 @@ class OneGridRowActionComponent {
4122
4212
  this.onRowCellOption.emit(data);
4123
4213
  }
4124
4214
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowActionComponent, deps: [{ token: OneGridCellService }], target: i0.ɵɵFactoryTarget.Component }); }
4125
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridRowActionComponent, isStandalone: true, selector: "one-grid-row-action", inputs: { column: "column", node: "node", allowedEdit: "allowedEdit", masterDetail: "masterDetail", masterNode: "masterNode", cellRendererParams: "cellRendererParams", gridType: "gridType", context: "context" }, outputs: { onRowGotoDetail: "onRowGotoDetail", onRowAddNew: "onRowAddNew", onRowView: "onRowView", onRowLocation: "onRowLocation", onRowDocument: "onRowDocument", onRowCopy: "onRowCopy", onRowDelete: "onRowDelete", onRowGotoList: "onRowGotoList", onRowEdit: "onRowEdit", onRowPrint: "onRowPrint", onRowHistory: "onRowHistory", onRowOption: "onRowOption", onRowLanguage: "onRowLanguage", onRowCellOption: "onRowCellOption" }, ngImport: i0, template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <!-- A button, not an <a> with a click handler: it has no href, so\n it was neither focusable nor operable from the keyboard. -->\n <button\n type=\"button\"\n class=\"btn-action btn-action-plain me-2\"\n [attr.aria-expanded]=\"node.detailActive\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </button>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.gotoDetail\"\n [title]=\"labels.gotoDetail\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.addNew\"\n [title]=\"labels.addNew\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.view\"\n [title]=\"labels.view\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.location\"\n [title]=\"labels.location\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.document\"\n [title]=\"labels.document\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.copy\"\n [title]=\"labels.copy\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.delete\"\n [title]=\"labels.delete\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if (cellRendererParams?.gotoListButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n [attr.aria-label]=\"labels.gotoList\"\n [title]=\"labels.gotoList\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.edit\"\n [title]=\"labels.edit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.print\"\n [title]=\"labels.print\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.history\"\n [title]=\"labels.history\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.option\"\n [title]=\"labels.option\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.language\"\n [title]=\"labels.language\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Optoion Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.cellOption\"\n [title]=\"labels.cellOption\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
4215
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.12", type: OneGridRowActionComponent, isStandalone: true, selector: "one-grid-row-action", inputs: { column: "column", node: "node", allowedEdit: "allowedEdit", masterDetail: "masterDetail", masterNode: "masterNode", cellRendererParams: "cellRendererParams", gridType: "gridType", context: "context" }, outputs: { onRowGotoDetail: "onRowGotoDetail", onRowAddNew: "onRowAddNew", onRowView: "onRowView", onRowLocation: "onRowLocation", onRowDocument: "onRowDocument", onRowCopy: "onRowCopy", onRowDelete: "onRowDelete", onRowGotoList: "onRowGotoList", onRowEdit: "onRowEdit", onRowPrint: "onRowPrint", onRowHistory: "onRowHistory", onRowOption: "onRowOption", onRowLanguage: "onRowLanguage", onRowCellOption: "onRowCellOption" }, ngImport: i0, template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <!-- A button, not an <a> with a click handler: it has no href, so\n it was neither focusable nor operable from the keyboard. -->\n <button\n type=\"button\"\n class=\"btn-action btn-action-plain me-2\"\n [attr.aria-expanded]=\"node.detailActive\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </button>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.gotoDetail\"\n [title]=\"labels.gotoDetail\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.addNew\"\n [title]=\"labels.addNew\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.view\"\n [title]=\"labels.view\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.location\"\n [title]=\"labels.location\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.document\"\n [title]=\"labels.document\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.copy\"\n [title]=\"labels.copy\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.delete\"\n [title]=\"labels.delete\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if ((cellRendererParams?.gotoListButtonStatus === 1 && !(gotoListExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n [attr.aria-label]=\"labels.gotoList\"\n [title]=\"labels.gotoList\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.edit\"\n [title]=\"labels.edit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.print\"\n [title]=\"labels.print\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.history\"\n [title]=\"labels.history\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.option\"\n [title]=\"labels.option\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.language\"\n [title]=\"labels.language\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Option Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.cellOption\"\n [title]=\"labels.cellOption\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] }); }
4126
4216
  }
4127
4217
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: OneGridRowActionComponent, decorators: [{
4128
4218
  type: Component,
4129
- args: [{ standalone: true, imports: [NgClass], selector: 'one-grid-row-action', template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <!-- A button, not an <a> with a click handler: it has no href, so\n it was neither focusable nor operable from the keyboard. -->\n <button\n type=\"button\"\n class=\"btn-action btn-action-plain me-2\"\n [attr.aria-expanded]=\"node.detailActive\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </button>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.gotoDetail\"\n [title]=\"labels.gotoDetail\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.addNew\"\n [title]=\"labels.addNew\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.view\"\n [title]=\"labels.view\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.location\"\n [title]=\"labels.location\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.document\"\n [title]=\"labels.document\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.copy\"\n [title]=\"labels.copy\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.delete\"\n [title]=\"labels.delete\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if (cellRendererParams?.gotoListButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n [attr.aria-label]=\"labels.gotoList\"\n [title]=\"labels.gotoList\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.edit\"\n [title]=\"labels.edit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.print\"\n [title]=\"labels.print\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.history\"\n [title]=\"labels.history\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.option\"\n [title]=\"labels.option\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.language\"\n [title]=\"labels.language\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Optoion Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.cellOption\"\n [title]=\"labels.cellOption\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}" }]
4219
+ args: [{ standalone: true, imports: [NgClass], selector: 'one-grid-row-action', template: "@if ((cellRendererParams && node?.leaf && !column?.autoGroupField && !(node.group && node.leafGroup)) || (column?.rowActionLevels?.includes(node.level) && column?.autoGroupField)) {\n <div class=\"btn-action-container\">\n\n <!-- Expansion Button Status -->\n @if ((cellRendererParams?.detailActiveButtonStatus == 1 && !(detailActiveExcludeLevels?.has(node.level)))) {\n <!-- A button, not an <a> with a click handler: it has no href, so\n it was neither focusable nor operable from the keyboard. -->\n <button\n type=\"button\"\n class=\"btn-action btn-action-plain me-2\"\n [attr.aria-expanded]=\"node.detailActive\"\n [attr.aria-label]=\"node.detailActive ? 'Collapse row' : 'Expand row'\"\n [title]=\"node.detailActive ? 'Collapse' : 'Expand'\"\n (click)=\"invokeRowToggleDetailActiveExpand(node)\">\n\n <i class=\"bi\" [ngClass]=\"{ 'bi-chevron-down': node.detailActive, 'bi-chevron-right': !node.detailActive }\"></i>\n </button>\n }\n\n <!-- Goto Detail Button Status -->\n @if ((cellRendererParams?.gotoDetailButtonStatus == 1 && !(gotoDetailExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.gotoDetail\"\n [title]=\"labels.gotoDetail\"\n (click)=\"invokeRowActionGotoDetail(node, column)\">\n\n <i class=\"bi bi-list-task\"></i>\n </button>\n }\n\n <!-- Add New Button Status -->\n @if ((cellRendererParams?.addNewButtonStatus == 1 && !(addNewExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.addNew\"\n [title]=\"labels.addNew\"\n (click)=\"invokeRowActionAddNew(node, column)\">\n\n <i class=\"bi bi-plus\"></i>\n </button>\n }\n\n <!-- View Button Status -->\n @if (cellRendererParams?.viewButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.view\"\n [title]=\"labels.view\"\n (click)=\"invokeRowActionView(node, column)\">\n\n <i class=\"bi bi-eye\"></i>\n </button>\n }\n @if (cellRendererParams?.locationButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.location\"\n [title]=\"labels.location\"\n (click)=\"invokeRowActionLocation(node, column)\">\n\n <i class=\"bi bi-geo-alt\"></i>\n </button>\n }\n\n <!-- Document Button Status -->\n @if (cellRendererParams?.documentButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.document\"\n [title]=\"labels.document\"\n (click)=\"invokeRowActionDocument(node, column)\">\n\n <i class=\"bi bi-file-earmark-text\"></i>\n </button>\n }\n\n <!-- Copy Button Status -->\n @if (cellRendererParams?.copyButtonStatus == 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [attr.aria-label]=\"labels.copy\"\n [title]=\"labels.copy\"\n (click)=\"invokeRowActionCopy(node, column)\">\n\n <i class=\"bi bi-files\"></i>\n </button>\n }\n\n\n <!-- Delete Button Status -->\n @if (cellRendererParams?.deleteButtonStatus == 1 && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-danger\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.delete\"\n [title]=\"labels.delete\"\n (click)=\"invokeRowActionDelete(node, column)\">\n\n <i class=\"bi bi-trash3\"></i>\n </button>\n }\n\n <!-- Goto List Button Status -->\n @if ((cellRendererParams?.gotoListButtonStatus === 1 && !(gotoListExcludeLevels?.has(node.level))) && (!hideActionButton || allowedEdit)) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-success\"\n [attr.aria-label]=\"labels.gotoList\"\n [title]=\"labels.gotoList\"\n (click)=\"invokeRowActionGotoList(node, column)\">\n\n <i class=\"bi bi-list-ul\"></i>\n </button>\n }\n\n <!-- Edit Button Status -->\n @if (cellRendererParams?.editButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.edit\"\n [title]=\"labels.edit\"\n (click)=\"invokeRowActionEdit(node, column)\">\n\n <i class=\"bi bi-pencil\"></i>\n </button>\n }\n\n <!-- Print Button Status -->\n @if (cellRendererParams?.printButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.print\"\n [title]=\"labels.print\"\n (click)=\"invokeRowActionPrint(node, column)\">\n\n <i class=\"bi bi-printer\"></i>\n </button>\n }\n\n <!-- History Button Status -->\n @if (cellRendererParams?.historyButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.history\"\n [title]=\"labels.history\"\n (click)=\"invokeRowActionHistory(node, column)\">\n\n <i class=\"bi bi-clock-history\"></i>\n </button>\n }\n\n <!-- Option Button Status -->\n @if (cellRendererParams?.optionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.option\"\n [title]=\"labels.option\"\n (click)=\"invokeRowActionOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n\n <!-- Language Button Status -->\n @if (cellRendererParams?.languageButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.language\"\n [title]=\"labels.language\"\n (click)=\"invokeRowActionLanguage(node, column)\">\n\n <i class=\"bi bi-translate\"></i>\n </button>\n }\n\n <!-- Cell Option Button Status (Context Menu) -->\n @if (cellRendererParams?.cellOptionButtonStatus === 1) {\n <button\n type=\"button\"\n class=\"btn-action btn-action-primary border-0 text-body\"\n [style.background]=\"'transparent'\"\n [class.disabled]=\"actionDisabled\"\n [disabled]=\"actionDisabled\"\n [attr.aria-label]=\"labels.cellOption\"\n [title]=\"labels.cellOption\"\n (click)=\"invokeRowActionCellOption(node, column)\">\n\n <i class=\"bi bi-three-dots-vertical\"></i>\n </button>\n }\n </div>\n}" }]
4130
4220
  }], ctorParameters: () => [{ type: OneGridCellService }], propDecorators: { column: [{
4131
4221
  type: Input,
4132
4222
  args: [{ required: true }]
@@ -4137,15 +4227,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
4137
4227
  type: Input,
4138
4228
  args: [{ required: true }]
4139
4229
  }], masterDetail: [{
4140
- type: Input
4230
+ type: Input,
4231
+ args: [{ required: false }]
4141
4232
  }], masterNode: [{
4142
- type: Input
4233
+ type: Input,
4234
+ args: [{ required: false }]
4143
4235
  }], cellRendererParams: [{
4144
- type: Input
4236
+ type: Input,
4237
+ args: [{ required: false }]
4145
4238
  }], gridType: [{
4146
- type: Input
4239
+ type: Input,
4240
+ args: [{ required: false }]
4147
4241
  }], context: [{
4148
- type: Input
4242
+ type: Input,
4243
+ args: [{ required: false }]
4149
4244
  }], onRowGotoDetail: [{
4150
4245
  type: Output
4151
4246
  }], onRowAddNew: [{
@@ -6106,6 +6201,20 @@ class OneGridComponent {
6106
6201
  this.bodyScrollLeft = 0;
6107
6202
  this._oneRowNumberColumnDef = null;
6108
6203
  this.subscriptions = new Subscription();
6204
+ /**
6205
+ * Row grouping, as the grid sees it.
6206
+ *
6207
+ * The three `_host*` fields hold what was bound before grouping touched
6208
+ * anything, because grouping is reversible: turn it off and the columns,
6209
+ * the group column and the grid type all have to go back to what the host
6210
+ * asked for. `_appliedGroupFields` is the grouping the registered columns
6211
+ * currently reflect — the row model's copy lives in `api.rowGroupFields`.
6212
+ */
6213
+ this._hostColumnDefs = [];
6214
+ this._hostAutoGroupColumnDef = null;
6215
+ this._hostGridType = 'master';
6216
+ this._hostTreeData = false;
6217
+ this._appliedGroupFields = [];
6109
6218
  /**
6110
6219
  * Totals for `aria-rowcount` / `aria-colcount`.
6111
6220
  *
@@ -6164,29 +6273,25 @@ class OneGridComponent {
6164
6273
  * tree over synthetic group rows. Configured before `api.init` because
6165
6274
  * everything downstream — the treeData flag the API captures, the group
6166
6275
  * column the tree block below prepends — has to see the tree shape.
6276
+ *
6277
+ * What the host declared is kept as it was given: regrouping at runtime
6278
+ * re-derives the registered columns from it, so a column hidden because
6279
+ * it was grouped comes back when it stops being, and one the host hid
6280
+ * itself stays hidden.
6167
6281
  */
6282
+ this._hostColumnDefs = this.columnDefs ?? [];
6283
+ this._hostAutoGroupColumnDef = this.autoGroupColumnDef;
6284
+ this._hostGridType = this.gridType;
6285
+ this._hostTreeData = this.treeData;
6168
6286
  const rowGroupColumnFields = this.treeData || this.masterDetail
6169
6287
  ? []
6170
6288
  : rowGroupFields(this.columnDefs);
6171
6289
  if (rowGroupColumnFields.length) {
6290
+ this._appliedGroupFields = rowGroupColumnFields;
6172
6291
  this.treeData = true;
6173
6292
  this.treeDataChildrenField = ONE_GROUP_CHILDREN_FIELD;
6174
- // The group column: host-tuned through autoGroupColumnDef, but its
6175
- // field is always the synthetic label — that is where a group row
6176
- // carries its display value.
6177
- this.autoGroupColumnDef = {
6178
- headerName: 'Group',
6179
- minWidth: 200,
6180
- ...this.autoGroupColumnDef,
6181
- field: ONE_GROUP_VALUE_FIELD,
6182
- // The marker the tree machinery keys on: the expander renders on this
6183
- // column and group rows print their label here.
6184
- autoGroupField: true,
6185
- };
6186
- // A grouped-by column's value is on the group row; showing the flat
6187
- // column too repeats it down every leaf. Hidden, not removed — the
6188
- // host can bring it back with api.setColumnVisible.
6189
- this.columnDefs = this.columnDefs.map(column => column.rowGroup ? { ...column, hide: true } : column);
6293
+ this.autoGroupColumnDef = this.buildAutoGroupColumnDef();
6294
+ this.columnDefs = this.groupedColumnDefs(rowGroupColumnFields);
6190
6295
  }
6191
6296
  /**
6192
6297
  * Initialize One Grid API
@@ -6201,11 +6306,21 @@ class OneGridComponent {
6201
6306
  masterDetail: this.masterDetail,
6202
6307
  detailCellRendererParams: this.detailCellRendererParams,
6203
6308
  detailRendererComponent: this.detailRendererComponent,
6204
- treeData: this.treeData,
6309
+ // The host's own tree data, not the tree grouping builds: `setRowGrouping`
6310
+ // turns that on below, and the API has to be able to tell whose tree it
6311
+ // is before it may replace one.
6312
+ treeData: this._hostTreeData,
6205
6313
  });
6206
6314
  if (rowGroupColumnFields.length) {
6207
6315
  this.api.setRowGrouping(rowGroupColumnFields, aggColumns(this.columnDefs));
6208
6316
  }
6317
+ // Regrouping at runtime. `api.setRowGrouping` owns the row model half of
6318
+ // the switch; this is the other half — the columns the grid registers and
6319
+ // the shape the body renders. Subscribed after the initial call above,
6320
+ // which `ngOnInit` has already applied.
6321
+ this.subscriptions.add(this.eventService.addEventListener('rowGroupingChanged', (payload) => {
6322
+ this.applyRowGroupingColumns(payload.groupFields);
6323
+ }));
6209
6324
  if (this.undoRedoCellEditing) {
6210
6325
  this.api.enableUndoRedoCellEditing(this.undoRedoCellEditingLimit);
6211
6326
  }
@@ -6219,7 +6334,7 @@ class OneGridComponent {
6219
6334
  this.api.setGroupDefaultExpanded(this.groupDefaultExpanded);
6220
6335
  this.api.setGetDetailRowData(this.detailCellRendererParams?.getDetailRowData ?? null);
6221
6336
  if (this.rowNumber) {
6222
- const columnDefs = _.concat(this._oneRowNumberColumnDef, this.columnDefs);
6337
+ const columnDefs = lodash.concat(this._oneRowNumberColumnDef, this.columnDefs);
6223
6338
  setTimeout(() => this.api.setColumnDefs(columnDefs));
6224
6339
  }
6225
6340
  }
@@ -6228,10 +6343,9 @@ class OneGridComponent {
6228
6343
  */
6229
6344
  if (this.treeData) {
6230
6345
  this.gridType = 'tree';
6231
- const columnDefs = this.rowNumber ? _.concat(this._oneRowNumberColumnDef, this.autoGroupColumnDef, this.columnDefs) : _.concat(this.autoGroupColumnDef, this.columnDefs);
6232
6346
  this.api.setTreeDataChildrenField(this.treeDataChildrenField);
6233
6347
  this.api.setGroupDefaultExpanded(this.groupDefaultExpanded);
6234
- setTimeout(() => this.api.setColumnDefs(columnDefs));
6348
+ setTimeout(() => this.api.setColumnDefs(this.columnStack()));
6235
6349
  }
6236
6350
  // Listen Selection Changed Event
6237
6351
  // Columns can be replaced at runtime through `api.setColumnDefs`, and
@@ -6257,6 +6371,69 @@ class OneGridComponent {
6257
6371
  this.columnResized.emit(payload);
6258
6372
  }));
6259
6373
  }
6374
+ /**
6375
+ * The group column: host-tuned through `autoGroupColumnDef`, but its field
6376
+ * is always the synthetic label — that is where a group row carries its
6377
+ * display value — and it always carries the marker the tree machinery keys
6378
+ * on, which is what puts the expander on this column.
6379
+ */
6380
+ buildAutoGroupColumnDef() {
6381
+ return {
6382
+ headerName: 'Group',
6383
+ minWidth: 200,
6384
+ ...this._hostAutoGroupColumnDef,
6385
+ field: ONE_GROUP_VALUE_FIELD,
6386
+ autoGroupField: true,
6387
+ };
6388
+ }
6389
+ /**
6390
+ * The host's columns with the grouped-by ones hidden.
6391
+ *
6392
+ * A grouped-by column's value is on the group row; showing the flat column
6393
+ * too repeats it down every leaf. Hidden, not removed — the host can bring
6394
+ * one back with `api.setColumnVisible`, and ungrouping restores whatever
6395
+ * visibility the host itself declared.
6396
+ */
6397
+ groupedColumnDefs(groupFields) {
6398
+ return this._hostColumnDefs.map(column => column.field && groupFields.includes(column.field) ? { ...column, hide: true } : column);
6399
+ }
6400
+ /** The columns the grid registers: row numbers, the group column, the host's. */
6401
+ columnStack() {
6402
+ return lodash.compact([
6403
+ this.rowNumber ? this._oneRowNumberColumnDef : null,
6404
+ this.treeData ? this.autoGroupColumnDef : null,
6405
+ ...this.columnDefs,
6406
+ ]);
6407
+ }
6408
+ /**
6409
+ * Re-plumb everything grouping owns outside the row model: tree mode, the
6410
+ * children field, the group column, and which of the host's columns are
6411
+ * hidden because their value now shows on a group row.
6412
+ *
6413
+ * Driven by `rowGroupingChanged`, so a host regroups through one call —
6414
+ * `api.setRowGrouping(['country', 'city'])` — instead of re-creating the
6415
+ * grid. Grouping and host tree data are mutually exclusive, which the API
6416
+ * enforces, so this only ever switches a tree that grouping itself built.
6417
+ */
6418
+ applyRowGroupingColumns(groupFields) {
6419
+ const unchanged = groupFields.length === this._appliedGroupFields.length
6420
+ && groupFields.every((field, index) => field === this._appliedGroupFields[index]);
6421
+ if (unchanged)
6422
+ return;
6423
+ const grouping = groupFields.length > 0;
6424
+ this._appliedGroupFields = [...groupFields];
6425
+ this.treeData = grouping;
6426
+ this.treeDataChildrenField = grouping ? ONE_GROUP_CHILDREN_FIELD : null;
6427
+ this.gridType = grouping ? 'tree' : this._hostGridType;
6428
+ this.autoGroupColumnDef = grouping ? this.buildAutoGroupColumnDef() : this._hostAutoGroupColumnDef;
6429
+ this.columnDefs = this.groupedColumnDefs(groupFields);
6430
+ this.api.setGroupDefaultExpanded(this.groupDefaultExpanded);
6431
+ this.api.setColumnDefs(this.columnStack());
6432
+ // The grid type, the tree flag and the group column are all rendered
6433
+ // through bindings, and this runs from an event rather than from a
6434
+ // template callback.
6435
+ this.cdr.markForCheck();
6436
+ }
6260
6437
  ngAfterViewInit() {
6261
6438
  // The header follows the body through (bodyScroll) -> [scrollLeft]. A second
6262
6439
  // subscription used to live here that queried '.one-grid-header-column' — a