diff --git a/packages/abc/st/index.en-US.md b/packages/abc/st/index.en-US.md index 673f10d06..93483e0e0 100644 --- a/packages/abc/st/index.en-US.md +++ b/packages/abc/st/index.en-US.md @@ -104,7 +104,7 @@ When an exception is thrown when parsing column data, *INVALID DATA* will be for | `reset(extraParams?: any, options?: STLoadOptions)` | Reset data and `pi` to `1`, including single multi-select, sort, filter status (Covered default state) | | `addRow(data: STData | STData[], options?: { index?: number })` | Add a rows in the table | | `removeRow(data: STData | STData[] | number)` | Remove a row in the table | -| `setRow(index: number | STData, item: STData, options?: { refreshSchema?: boolean; emitReload?: boolean })` | Sets the row value for the `index` in the table | +| `setRow(index: number | STData, item: STData, options?: { refreshSchema?: boolean; emitReload?: boolean; arrayProcessMethod?: boolean })` | Sets the row value for the `index` in the table | | `pureItem(itemOrIndex: STData | number)` | Return pure data, `st` internally maintains a set of data for caching, this part of data may affect the backend | | `clear(cleanStatus = true)` | Clear all data | | `clearStatus()` | Clean all status (like this: single multi-select, sort, filter status) | diff --git a/packages/abc/st/index.zh-CN.md b/packages/abc/st/index.zh-CN.md index a7eb83c23..1a0e40b6c 100644 --- a/packages/abc/st/index.zh-CN.md +++ b/packages/abc/st/index.zh-CN.md @@ -104,7 +104,7 @@ module: import { STModule } from '@delon/abc/st'; | `reset(extraParams?: any, options?: STLoadOptions)` | 重置且重新设置 `pi` 为 `1`,包含单多选、排序、过滤状态(同默认状态一并清除) | | `addRow(data: STData | STData[], options?: { index?: number })` | 添加行 | | `removeRow(data: STData | STData[] | number)` | 移除行 | -| `setRow(index: number | STData, item: STData, options?: { refreshSchema?: boolean; emitReload?: boolean })` | 修改行数据,支持部分字段更新 | +| `setRow(index: number | STData, item: STData, options?: { refreshSchema?: boolean; emitReload?: boolean; arrayProcessMethod?: boolean })` | 修改行数据,支持部分字段更新 | | `pureItem(itemOrIndex: STData | number)` | 返回纯净数据,`st` 内部会维护一组用于缓存的数据,这部分数据可能会影响后端 | | `clear(cleanStatus = true)` | 清空所有数据 | | `clearStatus()` | 清空所有状态(包含单多选、排序、过滤状态) | 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 });