@one-grid-core/angular 0.5.1 → 0.5.2
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.
|
@@ -4722,6 +4722,24 @@ class OneGridBodyComponent {
|
|
|
4722
4722
|
* MAX_BUFFER_PX keeps roughly twenty rows of overscan either side instead.
|
|
4723
4723
|
*/
|
|
4724
4724
|
this.MAX_BUFFER_PX = 600;
|
|
4725
|
+
/**
|
|
4726
|
+
* Params for a component cell renderer.
|
|
4727
|
+
*
|
|
4728
|
+
* The cell params, plus whatever the column declared in
|
|
4729
|
+
* `cellRendererParams` — a field that exists precisely so a renderer can be
|
|
4730
|
+
* configured per column, and that nothing had ever forwarded to it. Column
|
|
4731
|
+
* config goes first so the grid's own fields win a name collision.
|
|
4732
|
+
*/
|
|
4733
|
+
/**
|
|
4734
|
+
* Cached per cell, keyed on the identities that mean "this cell changed":
|
|
4735
|
+
* its cellStates object (replaced on every edit and state refresh) and its
|
|
4736
|
+
* data object. Building a fresh object per call — which a template method
|
|
4737
|
+
* does per change-detection pass — made the renderer directive see "params
|
|
4738
|
+
* changed" every pass and re-run the component's oneInit each time. A
|
|
4739
|
+
* renderer whose oneInit touched grid state (a custom tree expander is the
|
|
4740
|
+
* classic case) then re-triggered change detection and looped forever.
|
|
4741
|
+
*/
|
|
4742
|
+
this.rendererParamsCache = new Map();
|
|
4725
4743
|
// ---------------------------------------------------------------------------
|
|
4726
4744
|
// Cell navigation
|
|
4727
4745
|
//
|
|
@@ -4791,6 +4809,8 @@ class OneGridBodyComponent {
|
|
|
4791
4809
|
*/
|
|
4792
4810
|
this.subscriptions.add(this.eventService.addEventListener('columnChanged', (payload) => {
|
|
4793
4811
|
this.columnDefs = [...payload.columns];
|
|
4812
|
+
// Params carry the columnDef, so a column change invalidates them all.
|
|
4813
|
+
this.rendererParamsCache.clear();
|
|
4794
4814
|
this.cellRenderer = this.columnDefs.some(col => col.cellRendererComponent);
|
|
4795
4815
|
this.rowWidth = this.columnDefs.reduce((sum, col) => sum + resolveColumnWidth(col), 0);
|
|
4796
4816
|
// A column change can alter the width left for flex columns (a hide, a
|
|
@@ -4806,6 +4826,9 @@ class OneGridBodyComponent {
|
|
|
4806
4826
|
// The full post-filter count, reported before the page slice is taken,
|
|
4807
4827
|
// so the host's paging totals see everything.
|
|
4808
4828
|
this.rowCountChanged.emit(allNodes?.length ?? 0);
|
|
4829
|
+
// New rows, new renderer params — and removed rows leave no stale
|
|
4830
|
+
// cache entries behind.
|
|
4831
|
+
this.rendererParamsCache.clear();
|
|
4809
4832
|
const nodes = this.api.pageNodes(allNodes);
|
|
4810
4833
|
setTimeout(() => {
|
|
4811
4834
|
this.viewport?.checkViewportSize();
|
|
@@ -4834,6 +4857,7 @@ class OneGridBodyComponent {
|
|
|
4834
4857
|
* Listen Pinned Row Data Changed Event
|
|
4835
4858
|
*/
|
|
4836
4859
|
this.subscriptions.add(this.eventService.addEventListener('pinnedRowDataChanged', ({ side, nodes }) => {
|
|
4860
|
+
this.rendererParamsCache.clear();
|
|
4837
4861
|
if (side === 'top') {
|
|
4838
4862
|
this.pinnedTopNodes = nodes;
|
|
4839
4863
|
}
|
|
@@ -5416,16 +5440,14 @@ class OneGridBodyComponent {
|
|
|
5416
5440
|
cellParams(node, column) {
|
|
5417
5441
|
return this.cellService.cellParams(column, node);
|
|
5418
5442
|
}
|
|
5419
|
-
/**
|
|
5420
|
-
* Params for a component cell renderer.
|
|
5421
|
-
*
|
|
5422
|
-
* The cell params, plus whatever the column declared in
|
|
5423
|
-
* `cellRendererParams` — a field that exists precisely so a renderer can be
|
|
5424
|
-
* configured per column, and that nothing had ever forwarded to it. Column
|
|
5425
|
-
* config goes first so the grid's own fields win a name collision.
|
|
5426
|
-
*/
|
|
5427
5443
|
rendererParams(node, column) {
|
|
5428
|
-
|
|
5444
|
+
const key = getCellKey(node.rowId, column.field ?? column.id ?? '');
|
|
5445
|
+
const cached = this.rendererParamsCache.get(key);
|
|
5446
|
+
if (cached && cached.states === node.cellStates && cached.data === node.data)
|
|
5447
|
+
return cached.params;
|
|
5448
|
+
const params = { ...(column?.cellRendererParams ?? {}), ...this.cellParams(node, column) };
|
|
5449
|
+
this.rendererParamsCache.set(key, { states: node.cellStates, data: node.data, params });
|
|
5450
|
+
return params;
|
|
5429
5451
|
}
|
|
5430
5452
|
/**
|
|
5431
5453
|
* `aria-rowindex` is 1-based over the whole grid, not over what is rendered.
|