From 2c48f527af04aacd3802e0ea12c3db8d61b57111 Mon Sep 17 00:00:00 2001 From: cipchk Date: Wed, 27 Nov 2024 14:16:45 +0800 Subject: [PATCH] feat(abc:st): add `arrayProcessMethod` in `setRow` --- packages/abc/st/st.component.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/abc/st/st.component.ts b/packages/abc/st/st.component.ts index f50a29179..d9aa42a58 100644 --- a/packages/abc/st/st.component.ts +++ b/packages/abc/st/st.component.ts @@ -604,12 +604,26 @@ export class STComponent implements AfterViewInit, OnChanges { * this.st.setRow(item, { price: 100 }) * ``` */ - setRow(index: number | STData, item: STData, options?: { refreshSchema?: boolean; emitReload?: boolean }): this { + setRow( + index: number | STData, + item: STData, + options?: { + refreshSchema?: boolean; + emitReload?: boolean; + /** + * + * @param arrayProcessMethod 数组处理方式 + * - `true` 表示替换新值,不管新值为哪种类型 + * - `false` 表示会合并整个数组(将旧数据与新数据合并成新数组) + */ + arrayProcessMethod?: boolean; + } + ): this { options = { refreshSchema: false, emitReload: false, ...options }; if (typeof index !== 'number') { index = this._data.indexOf(index); } - this._data[index] = deepMergeKey(this._data[index], false, item); + this._data[index] = deepMergeKey(this._data[index], options?.arrayProcessMethod ?? false, item); this.optimizeData(); if (options.refreshSchema) { this.resetColumns({ emitReload: options.emitReload });