Skip to content

Commit

Permalink
feat(cell): setDataSilently
Browse files Browse the repository at this point in the history
  • Loading branch information
Sorryhx committed Jun 4, 2024
1 parent 13cd329 commit a158491
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/x6/src/model/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,13 @@ export class Cell<
return this
}

setDataSilently<T = Properties['data']>(
data: T,
options: Cell.SetOptions = {},
) {
return this.setData(data, { ...options, silent: true })
}

replaceData<T = Properties['data']>(data: T, options: Cell.SetOptions = {}) {
return this.setData(data, { ...options, overwrite: true })
}
Expand Down
16 changes: 16 additions & 0 deletions sites/x6-sites/docs/api/model/cell.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,22 @@ node.setData({
}) // 此时会触发节点重绘
```

#### setDataSilently(...)

```ts
setDataSilently(data: any, options: Cell.SetOptions = {}): this
```

静默设置关联的数据,不触发`change:data`事件和画布重绘,相当于调用 `setData(data, { ...options, silent: true })`

| 名称 | 类型 | 必选 | 默认值 | 描述 |
|------------------|---------|:----:|---------|--------------------------------------------------|
| data | any || | |
| options.overwrite | boolean | | `false` |`true` 时替换现有值,否则根据 `options.deep` 选项进行深度或浅度 merge。 |
| options.deep | boolean | | `true` |`options.overwrite``false` 时有效, 为 `true` 时进行深度 merge,否则进行浅 merge。 |
| options...others | object | | | 其他自定义键值对,可以在事件回调中使用。 |


#### replaceData(...)

```ts
Expand Down

0 comments on commit a158491

Please sign in to comment.