Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cell): setDataSilently #4334

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading